2024-07-30 23:12:59 +00:00
|
|
|
#Kernel module makes here
|
|
|
|
PWD := $(CURDIR)
|
|
|
|
|
2024-07-31 19:13:06 +00:00
|
|
|
CC := gcc
|
|
|
|
CCLD := $(CC)
|
|
|
|
LD := ld
|
|
|
|
CFLAGS :=
|
|
|
|
LDFLAGS :=
|
2024-07-30 23:12:59 +00:00
|
|
|
|
2024-07-31 19:13:06 +00:00
|
|
|
IPT_CFLAGS := -Wall -Wpedantic -O2
|
2024-07-30 23:12:59 +00:00
|
|
|
|
2024-07-31 19:13:06 +00:00
|
|
|
.PHONY: kmake kload kunload kreload kclean kmclean xclean
|
|
|
|
kmake: kmod xmod
|
|
|
|
|
|
|
|
kmod:
|
2024-07-30 23:12:59 +00:00
|
|
|
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
|
|
|
|
|
2024-09-01 13:52:41 +00:00
|
|
|
xmod: libipt_YTUNBLOCK.so libip6t_YTUNBLOCK.so
|
2024-07-31 19:13:06 +00:00
|
|
|
|
|
|
|
libipt_YTUNBLOCK.so: libipt_YTUNBLOCK.o
|
|
|
|
$(CCLD) -shared -fPIC ${IPT_CFLAGS} -o $@ $^;
|
|
|
|
|
|
|
|
libipt_YTUNBLOCK.o: libipt_YTUNBLOCK.c
|
|
|
|
$(CC) ${IPT_CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
|
|
|
|
|
2024-09-01 13:52:41 +00:00
|
|
|
libip6t_YTUNBLOCK.so: libip6t_YTUNBLOCK.o
|
|
|
|
$(CCLD) -shared -fPIC ${IPT_CFLAGS} -o $@ $^;
|
|
|
|
|
|
|
|
libip6t_YTUNBLOCK.o: libip6t_YTUNBLOCK.c
|
|
|
|
$(CC) ${IPT_CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
|
|
|
|
|
2024-07-30 23:12:59 +00:00
|
|
|
kload:
|
2024-07-31 19:13:06 +00:00
|
|
|
insmod ipt_YTUNBLOCK.ko
|
|
|
|
cp ./libipt_YTUNBLOCK.so /usr/lib/xtables/
|
2024-09-01 13:52:41 +00:00
|
|
|
cp ./libip6t_YTUNBLOCK.so /usr/lib/xtables/
|
2024-07-30 23:12:59 +00:00
|
|
|
|
|
|
|
kunload:
|
2024-07-31 19:13:06 +00:00
|
|
|
-rmmod ipt_YTUNBLOCK
|
|
|
|
-/bin/rm /usr/lib/xtables/libipt_YTUNBLOCK.so
|
2024-09-01 13:52:41 +00:00
|
|
|
-/bin/rm /usr/lib/xtables/libip6t_YTUNBLOCK.so
|
2024-07-30 23:12:59 +00:00
|
|
|
|
|
|
|
kreload: kunload kload
|
|
|
|
|
2024-07-31 19:13:06 +00:00
|
|
|
kclean: xtclean kmclean
|
2024-07-30 23:12:59 +00:00
|
|
|
|
2024-07-31 19:13:06 +00:00
|
|
|
kmclean:
|
|
|
|
-$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
|
2024-07-30 23:12:59 +00:00
|
|
|
|
2024-07-31 19:13:06 +00:00
|
|
|
xtclean:
|
|
|
|
-/bin/rm -f libipt_YTUNBLOCK.so libipt_YTUNBLOCK.o
|