From 91536ddbd0661c8797dbfb629361e6f214c4ecfd Mon Sep 17 00:00:00 2001 From: Tomas 'ZeXx86' Jedrzejek Date: Thu, 24 Jul 2008 15:28:36 +0200 Subject: [PATCH] added IPv6 tunnel support; added tunconfig command for configure tunnel server address; fixed bug in mount utility; better apps scripts; no-stack-protector in apps makefile; better Makefile - it generate config.h and build.h; code is without warnings now --- apps/calc/Makefile | 2 +- apps/calc/make_img.sh | 11 +- apps/edit/Makefile | 2 +- apps/edit/make_img.sh | 11 +- apps/imgshow/Makefile | 2 +- apps/imgshow/make_img.sh | 11 +- apps/invaders/Makefile | 2 +- apps/invaders/make_img.sh | 11 +- apps/irc/Makefile | 2 +- apps/irc/make_img.sh | 11 +- apps/nc/Makefile | 2 +- apps/nc/make_img.sh | 11 +- apps/openchess/src/makefile-zexos | 2 +- apps/sh/Makefile | 2 +- apps/sh/make_img.sh | 11 +- apps/telnetd/Makefile | 2 +- apps/telnetd/make_img.sh | 11 +- apps/tutorial/make_img.sh | 11 +- apps/tutorial/myapp/Makefile | 2 +- apps/tuxanci/Makefile | 2 +- apps/tuxanci/make_img.sh | 11 +- apps/webcl/Makefile | 2 +- apps/webcl/make_img.sh | 11 +- apps/websrv/Makefile | 2 +- apps/websrv/make_img.sh | 11 +- apps/wm/Makefile | 2 +- apps/wm/make_img.sh | 11 +- kernel/.config | 11 +- kernel/Kconfig | 22 ++++ kernel/Makefile | 12 ++- kernel/arch/i386/gdt.c | 3 +- kernel/arch/i386/idt.c | 3 +- kernel/build/i386/build.h | 15 --- kernel/build/i386/config.h | 41 -------- kernel/core/commands.c | 90 +++++++++++------ kernel/core/net/icmp6.c | 97 +++++++++++++----- kernel/core/net/if.c | 6 ++ kernel/core/net/ip.c | 9 +- kernel/core/net/ipv6.c | 73 +++++++------- kernel/core/net/ndp.c | 1 + kernel/core/net/packet.c | 8 ++ kernel/core/net/tcp6.c | 80 +++++++++++---- kernel/core/net/tun6.c | 122 +++++++++++++++++++++++ kernel/core/net/udp6.c | 78 +++++++++++---- kernel/core/vfs.c | 7 +- kernel/include/net/dns.h | 3 +- kernel/include/net/ip.h | 4 + kernel/{lib/stdio/fclose.c => include/net/tun.h} | 18 ++-- kernel/include/stdio.h | 3 + kernel/include/system.h | 3 + kernel/kernel.mak | 6 +- kernel/lib/mm/mem.c | 4 +- kernel/lib/stdio/delay.c | 18 +--- kernel/lib/stdio/fclose.c | 4 +- kernel/lib/stdio/fgets.c | 3 +- kernel/lib/stdio/fopen.c | 3 +- kernel/lib/stdio/kprintf.c | 4 +- kernel/lib/stdio/open.c | 11 +- kernel/lib/stdio/printf.c | 3 +- kernel/lib/stdio/puts.c | 8 +- kernel/lib/string/strcat.c | 10 +- kernel/lib/unistd/fcntl.c | 2 + libc/unistd/dup.c | 2 + libx/cursor/xcursor.c | 5 +- 64 files changed, 681 insertions(+), 282 deletions(-) delete mode 100644 kernel/build/i386/build.h delete mode 100644 kernel/build/i386/config.h create mode 100644 kernel/core/net/tun6.c copy kernel/{lib/stdio/fclose.c => include/net/tun.h} (78%) diff --git a/apps/calc/Makefile b/apps/calc/Makefile index 23aae94..6f369a4 100644 --- a/apps/calc/Makefile +++ b/apps/calc/Makefile @@ -8,7 +8,7 @@ DLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(DLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(DLIBC)/libc.a diff --git a/apps/calc/make_img.sh b/apps/calc/make_img.sh index d610ca4..a3c9e07 100755 --- a/apps/calc/make_img.sh +++ b/apps/calc/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="calc" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/edit/Makefile b/apps/edit/Makefile index dc94817..27701fa 100644 --- a/apps/edit/Makefile +++ b/apps/edit/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/edit/make_img.sh b/apps/edit/make_img.sh index 368bf20..087e461 100755 --- a/apps/edit/make_img.sh +++ b/apps/edit/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="edit" @@ -14,4 +17,10 @@ mount -oloop $APPNAME.img floppy cp $APPNAME floppy cp file floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/imgshow/Makefile b/apps/imgshow/Makefile index 08ffa48..2805f84 100644 --- a/apps/imgshow/Makefile +++ b/apps/imgshow/Makefile @@ -9,7 +9,7 @@ LIBXDIR =../../libx LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) -I$(LIBXDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) -I$(LIBXDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/imgshow/make_img.sh b/apps/imgshow/make_img.sh index 4ef2e5a..14e9ce9 100755 --- a/apps/imgshow/make_img.sh +++ b/apps/imgshow/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="imgshow" @@ -14,4 +17,10 @@ mount -oloop $APPNAME.img floppy cp $APPNAME floppy cp rocket floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/invaders/Makefile b/apps/invaders/Makefile index 41586e2..e12dc68 100644 --- a/apps/invaders/Makefile +++ b/apps/invaders/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/invaders/make_img.sh b/apps/invaders/make_img.sh index cabf76d..264919e 100755 --- a/apps/invaders/make_img.sh +++ b/apps/invaders/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="invaders" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/irc/Makefile b/apps/irc/Makefile index c3812ac..495a7db 100644 --- a/apps/irc/Makefile +++ b/apps/irc/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/irc/make_img.sh b/apps/irc/make_img.sh index c884943..2b8e367 100755 --- a/apps/irc/make_img.sh +++ b/apps/irc/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="irc" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/nc/Makefile b/apps/nc/Makefile index 5bdae88..da0a2ad 100644 --- a/apps/nc/Makefile +++ b/apps/nc/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/nc/make_img.sh b/apps/nc/make_img.sh index dd02be5..adc079e 100755 --- a/apps/nc/make_img.sh +++ b/apps/nc/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="nc" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/openchess/src/makefile-zexos b/apps/openchess/src/makefile-zexos index d1d39af..b9016a6 100644 --- a/apps/openchess/src/makefile-zexos +++ b/apps/openchess/src/makefile-zexos @@ -8,7 +8,7 @@ GLIBC =../../../libc LSCRIPT =./platform/zexos/link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -c -nostdinc -fno-builtin -I$(INCDIR) -Iplatform/zexos +CC =gcc -m32 -g -O2 -Wall -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) -Iplatform/zexos #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/sh/Makefile b/apps/sh/Makefile index 9acf2f8..0f411b2 100644 --- a/apps/sh/Makefile +++ b/apps/sh/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/sh/make_img.sh b/apps/sh/make_img.sh index ceb141b..d536e84 100755 --- a/apps/sh/make_img.sh +++ b/apps/sh/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="sh" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/telnetd/Makefile b/apps/telnetd/Makefile index 27407c7..3da5918 100644 --- a/apps/telnetd/Makefile +++ b/apps/telnetd/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/telnetd/make_img.sh b/apps/telnetd/make_img.sh index a8ce9cb..75949ba 100755 --- a/apps/telnetd/make_img.sh +++ b/apps/telnetd/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="telnetd" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/tutorial/make_img.sh b/apps/tutorial/make_img.sh index e23a109..845f6e6 100755 --- a/apps/tutorial/make_img.sh +++ b/apps/tutorial/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="myapp" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp -r ./$APPNAME/* floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/tutorial/myapp/Makefile b/apps/tutorial/myapp/Makefile index 521fa79..259b01d 100644 --- a/apps/tutorial/myapp/Makefile +++ b/apps/tutorial/myapp/Makefile @@ -8,7 +8,7 @@ GLIBC =../../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/tuxanci/Makefile b/apps/tuxanci/Makefile index 6c51dff..27a695b 100644 --- a/apps/tuxanci/Makefile +++ b/apps/tuxanci/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/tuxanci/make_img.sh b/apps/tuxanci/make_img.sh index d9be0f6..3278333 100755 --- a/apps/tuxanci/make_img.sh +++ b/apps/tuxanci/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="tuxanci" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/webcl/Makefile b/apps/webcl/Makefile index 3804ab9..35beba9 100644 --- a/apps/webcl/Makefile +++ b/apps/webcl/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/webcl/make_img.sh b/apps/webcl/make_img.sh index db91214..172ccb5 100755 --- a/apps/webcl/make_img.sh +++ b/apps/webcl/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="webcl" @@ -13,4 +16,10 @@ mkdir floppy mount -oloop $APPNAME.img floppy cp $APPNAME floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/websrv/Makefile b/apps/websrv/Makefile index c21c8db..da40d96 100644 --- a/apps/websrv/Makefile +++ b/apps/websrv/Makefile @@ -8,7 +8,7 @@ GLIBC =../../libc LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/websrv/make_img.sh b/apps/websrv/make_img.sh index da66148..75a1aac 100755 --- a/apps/websrv/make_img.sh +++ b/apps/websrv/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="websrv" @@ -14,4 +17,10 @@ mount -oloop $APPNAME.img floppy cp $APPNAME floppy cp html floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/apps/wm/Makefile b/apps/wm/Makefile index 2f34a88..49a6e7a 100644 --- a/apps/wm/Makefile +++ b/apps/wm/Makefile @@ -9,7 +9,7 @@ LIBXDIR =../../libx LSCRIPT =./link.ld LFLAGS =-g -T$(LSCRIPT) INCDIR =$(GLIBC)/include -CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -I$(INCDIR) -I$(LIBXDIR) +CC =gcc -m32 -g -O2 -Wall -W -c -nostdinc -fno-builtin -fno-stack-protector -I$(INCDIR) -I$(LIBXDIR) #-Wall -W LD =ld -m elf_i386 -s -nostdlib LIBC =$(GLIBC)/libc.a diff --git a/apps/wm/make_img.sh b/apps/wm/make_img.sh index 0f7843d..f38d458 100755 --- a/apps/wm/make_img.sh +++ b/apps/wm/make_img.sh @@ -1,4 +1,7 @@ #!/bin/bash + +if [ "$USER" = "root" ] ; then + # Folder name of your application APPNAME="wm" @@ -17,4 +20,10 @@ cp folder floppy cp file floppy cp config floppy umount floppy -rmdir floppy \ No newline at end of file +rmdir floppy + +else + +echo "Please start this script as root - it is needed for mount program" + +fi \ No newline at end of file diff --git a/kernel/.config b/kernel/.config index 54c2ab5..8cf230d 100644 --- a/kernel/.config +++ b/kernel/.config @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # ZeX/OS version: .. -# Sun Jul 13 11:00:28 2008 +# Thu Jul 24 15:07:00 2008 # # @@ -18,12 +18,19 @@ CONFIG_MEM_PAGING=y # CONFIG_MEM_DLALLOC is not set # +# Networking +# +CONFIG_PROTO_IPV4=y +CONFIG_PROTO_IPV6=y +CONFIG_PROTO_TUN6=y + +# # Device drivers # CONFIG_DRV_RS232=y CONFIG_DRV_ATA=y CONFIG_DRV_PCI=y -CONFIG_DRV_USB=y +# CONFIG_DRV_USB is not set CONFIG_DRV_PCNET32=y # CONFIG_DRV_RTL8029 is not set CONFIG_DRV_RTL8139=y diff --git a/kernel/Kconfig b/kernel/Kconfig index d1af44b..391f238 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -39,5 +39,27 @@ config MEM_DLALLOC endmenu +menu "Networking" + +config PROTO_IPV4 + bool "IPv4 protocol" + default y + help + IPv4 is a data-oriented protocol to be used on a packet switched internetwork (e.g., Ethernet). + +config PROTO_IPV6 + bool "IPv6 protocol" + default y + help + Internet Protocol version 6 (IPv6) is an Internet Layer protocol for packet-switched internetworks. It is designated as the successor of IPv4, the first and still dominant version of the Internet Protocol, for general use on the Internet. + +config PROTO_TUN6 + bool "(tun6) Tunnel broker protocol" + default y + help + This provide tunnel, where IPv6 is tunneled directly inside IPv4 by having the protocol field set to '41' (IPv6) in the IPv4 packet. + +endmenu + source "drivers/Kconfig" diff --git a/kernel/Makefile b/kernel/Makefile index 3a56372..50aab27 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -19,8 +19,8 @@ # Thanks for Alex Smith ZEXOS_VERSION = 0 -ZEXOS_PATCHLEVEL = 5 -ZEXOS_SUBLEVEL = 8 +ZEXOS_PATCHLEVEL = 6 +ZEXOS_SUBLEVEL = 0 ZEXOS_EXTRAVERSION = ZEXOS_CODENAME = @@ -52,7 +52,7 @@ else include $(src)/.config -all: prepare $(obj)/config.h $(obj)/build.h drivers +all: prepare $(obj)/config.h $(obj)/build.h compilation drivers @printf " DONE\n" endif @@ -70,8 +70,6 @@ prepare: $(Q)ln -s $(src)/build/$(ARCH) $(src)/build/main $(Q)if [ -e "$(src)/include/arch" ]; then rm $(src)/include/arch; fi $(Q)ln -s $(src)/arch/$(ARCH)/include $(src)/include/arch - $(Q)make -C arch/main - $(Q)make -C lib $(obj)/config.h: .config $(Q)make --no-print-directory silentoldconfig @@ -96,3 +94,7 @@ $(obj)/build.h: Makefile $(Q)printf "\n" >> $(obj)/build.h $(Q)printf "#define ZEXOS_ARCH \"$(ARCH)\"\n" >> $(obj)/build.h $(Q)printf "#define ARCH_$(ARCH)\n" >> $(obj)/build.h + +compilation: + $(Q)make -C arch/main + $(Q)make -C lib diff --git a/kernel/arch/i386/gdt.c b/kernel/arch/i386/gdt.c index fb57012..c1da14e 100755 --- a/kernel/arch/i386/gdt.c +++ b/kernel/arch/i386/gdt.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,7 +73,7 @@ unsigned int gdt_install () { /* Setup the GDT pointer and limit */ gp.limit = (sizeof(struct gdt_entry) * 3) - 1; - gp.base = &gdt; + gp.base = (unsigned int) &gdt; /* Our NULL descriptor */ gdt_set_gate(0, 0, 0, 0, 0); diff --git a/kernel/arch/i386/idt.c b/kernel/arch/i386/idt.c index 0b27686..82e5114 100755 --- a/kernel/arch/i386/idt.c +++ b/kernel/arch/i386/idt.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,7 +81,7 @@ unsigned int idt_install () { /* Sets the special IDT pointer up, just like in 'gdt.c' */ idtp.limit = (sizeof (struct idt_entry) * 256) - 1; - idtp.base = &idt; + idtp.base = (unsigned int) &idt; /* Clear out the entire IDT, initializing it to zeros */ memset(&idt, 0, sizeof(struct idt_entry) * 256); diff --git a/kernel/build/i386/build.h b/kernel/build/i386/build.h deleted file mode 100644 index f066713..0000000 --- a/kernel/build/i386/build.h +++ /dev/null @@ -1,15 +0,0 @@ -#define ZEXOS_MAJOR "0" -#define ZEXOS_MINOR "6" -#define ZEXOS_REVISION "0" -#define ZEXOS_EXTRAVER "" -#define ZEXOS_VERSION "" -#define ZEXOS_CODENAME "" -#define ZEXOS_DATE "2008-06-13 15:45:25" - -#define ZEXOS_COMPILER "gcc (GCC) 4.1.1 (Gentoo 4.1.1)" -#define ZEXOS_COMPILE_BY "tomas" -#define ZEXOS_COMPILE_HOST "gentoo" -#define ZEXOS_COMPILE_DOMAIN "" - -#define ZEXOS_ARCH "i386" -#define ARCH_i386 diff --git a/kernel/build/i386/config.h b/kernel/build/i386/config.h deleted file mode 100644 index f134789..0000000 --- a/kernel/build/i386/config.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Automatically generated C config: don't edit - * ZeX/OS version: .. - * Sun Jul 13 11:00:28 2008 - */ -#define AUTOCONF_INCLUDED - -/* - * User interface - */ -#define CONFIG_UI_KBD_LAYOUT "us" -#define CONFIG_UI_SHELL_INITCMD "" -#define CONFIG_UI_CONSOLELOG 32 - -/* - * Memory management - */ -#define CONFIG_MEM_PAGING 1 -#undef CONFIG_MEM_DLALLOC - -/* - * Device drivers - */ -#define CONFIG_DRV_RS232 1 -#define CONFIG_DRV_ATA 1 -#define CONFIG_DRV_PCI 1 -#define CONFIG_DRV_USB 1 -#define CONFIG_DRV_PCNET32 1 -#undef CONFIG_DRV_RTL8029 -#define CONFIG_DRV_RTL8139 1 -#define CONFIG_DRV_VGA 1 -#define CONFIG_DRV_VESA 1 -#define CONFIG_DRV_VGA_RES "320x200" -#define CONFIG_DRV_FAT12 1 -#undef CONFIG_DRV_FAT16 -#define CONFIG_DRV_EXT2 1 -#undef CONFIG_DRV_ZEXFS -#undef CONFIG_DRV_ISOFS -#define CONFIG_DRV_SPEAKER 1 -#define CONFIG_DRV_FLOPPY 1 -#define CONFIG_DRV_KEYBOARD 1 diff --git a/kernel/core/commands.c b/kernel/core/commands.c index 20d1ede..7a5f035 100755 --- a/kernel/core/commands.c +++ b/kernel/core/commands.c @@ -40,6 +40,7 @@ #include #include #include +#include #include command_t command_list; @@ -1222,39 +1223,26 @@ unsigned command_ifconfig (char *command, unsigned len) return 0; } - unsigned char a; - unsigned char b; - unsigned char c; - unsigned char d; + net_ipv4 ipv4; + net_ipv6 ipv6; + if (ipv4 = net_proto_ip_convert (ip)) { + netif_ip_addr (netif, ipv4); - unsigned g = 0; - unsigned i = 0; - - unsigned h[4]; - - while (i < y) { - if (ip[i] == '.') { - ip[i] = '\0'; - h[g] = i+1; - g ++; - } + printf ("%s: IPv4 ", ifid); + net_proto_ip_print (ipv4); + printf (" - OK\n"); + } else if (net_proto_ipv6_convert (ipv6, ip)) { + netif_ipv6_addr (netif, ipv6); - i ++; - } - - if (g != 3) { - printf ("ifconfig -> bad ip address format, example: 192.168.1.1\n"); + printf ("%s: IPv6 ", ifid); + net_proto_ipv6_print (ipv6); + printf (" - OK\n"); + } else { + printf ("ifconfig -> bad ip address format, example:\n\t\t192.168.1.1 for IPv4\n\t\tfc00:0:0:0:0:0:0:10 for IPv6\n"); return 0; } - - a = atoi (ip); - b = atoi (ip+h[0]); - c = atoi (ip+h[1]); - d = atoi (ip+h[2]); - - printf ("%s: %d.%d.%d.%d - OK\n", ifid, a, b, c, d); - return netif_ip_addr (netif, NET_IPV4_TO_ADDR (a, b, c, d)); + return 1; } unsigned command_ifroute (char *command, unsigned len) @@ -1348,6 +1336,45 @@ unsigned command_dnsconfig (char *command, unsigned len) return 1; } +unsigned command_tunconfig (char *command, unsigned len) +{ + strcpy (test, argparse (currtty->shell)); + + if (!test) + return 0; + + unsigned l = strlen (test); + + if (!l) { + printf ("tunconfig -> wrong syntax !\ntunconfig for enable or tunconfig 0 for disable\n"); + + return 0; + } + + /* you can disable this service over character '0' as parameter */ + if (l == 1 && test[0] == '0') { + tun6_addr (0); + + printf ("tunconfig: disabled - OK\n"); + + return 1; + } + + /* classical ipv4 address from tunnel server */ + net_ipv4 tunnel = net_proto_ip_convert (test); + + if (!tunnel) { + printf ("tunconfig -> wrong syntax !\nExample: tunconfig 216.66.80.30\n"); + + return 0; + } + + tun6_addr (tunnel); + + printf ("tunconfig: ::%s - OK\n", test); + + return 1; +} unsigned command_kbdmap (char *command, unsigned len) { @@ -1896,6 +1923,9 @@ unsigned int init_commands () command_register ("ifconfig", "Configure network interface", &command_ifconfig, 0); command_register ("ifroute", "Configure gateway address", &command_ifroute, 0); command_register ("dnsconfig", "Configure domain name server address", &command_dnsconfig, 0); +#ifdef CONFIG_PROTO_TUN6 + command_register ("tunconfig", "Configure IPv6 tunnel server address", &command_tunconfig, 0); +#endif command_register ("kbdmap", "Change keyboard layout", &command_kbdmap, 0); #ifdef CONFIG_DRV_ZEXFS command_register ("mkzexfs", "Create zexfs filesystem on hdd", &command_mkzexfs, 0); @@ -1903,8 +1933,12 @@ unsigned int init_commands () #ifdef CONFIG_DRV_EXT2 command_register ("mkext2", "Create ext2 filesystem on hdd", &command_mkext2, 0); #endif +#ifdef CONFIG_PROTO_IPV4 command_register ("ping", "Send ICMP echo request", &command_ping, 0); +#endif +#ifdef CONFIG_PROTO_IPV6 command_register ("ping6", "Send ICMPv6 echo request", &command_ping6, 0); +#endif command_register ("netexec", "Execute file from network", &command_netexec, 0); command_register ("savemode", "Make less cpu load", &command_savemode, 0); command_register ("cpuinfo", "Show CPU info", &command_cpuinfo, 0); diff --git a/kernel/core/net/icmp6.c b/kernel/core/net/icmp6.c index 4652e3e..8101741 100644 --- a/kernel/core/net/icmp6.c +++ b/kernel/core/net/icmp6.c @@ -27,6 +27,7 @@ #include #include #include +#include #include static unsigned net_icmp6_ping = 0; @@ -111,29 +112,59 @@ unsigned net_proto_icmp6_handler (packet_t *packet, proto_ipv6_t *ip, char *buf, unsigned net_proto_icmp6_request (netif_t *netif, net_ipv6 dest) { mac_addr_t mac_dest; - unsigned get = ndp_cache_get (dest, &mac_dest); - if (!get) { - ndp_send_request (netif, dest); - - unsigned i = 0; - /* 200ms for waiting on NDP reply */ - while (i < 200) { - get = ndp_cache_get (dest, &mac_dest); - - if (get) - break; - - /* TODO: make better waiting for ARP reply */ - timer_wait (1); - - schedule (); + if (!tun6_addr_get ()) { + unsigned get = ndp_cache_get (dest, &mac_dest); + + if (!get) { + ndp_send_request (netif, dest); + + unsigned i = 0; + /* 200ms for waiting on NDP reply */ + while (i < 200) { + get = ndp_cache_get (dest, &mac_dest); - i ++; + if (get) + break; + + /* TODO: make better waiting for ARP reply */ + timer_wait (1); + + schedule (); + + i ++; + } + + if (!get) + return 0; + } + } else { + /* IPv6 tunnel stuff */ + net_ipv4 tunnel = tun6_addr_get (); + unsigned get = arp_cache_get (tunnel, &mac_dest); + + if (!get) { + arp_send_request (netif, tunnel); + + unsigned i = 0; + /* 100ms for waiting on ARP reply */ + while (i < 100) { + get = arp_cache_get (tunnel, &mac_dest); + + if (get) + break; + + /* TODO: make better waiting for ARP reply */ + timer_wait (1); + + schedule (); + + i ++; + } + + if (!get) + return 0; } - - if (!get) - return 0; } /* packet header */ @@ -156,26 +187,32 @@ unsigned net_proto_icmp6_request (netif_t *netif, net_ipv6 dest) ip->ver = 0x60; ip->tclass = 0x0; ip->flabel = 0x0; - ip->pl_len = swap16 (56); + ip->pl_len = swap16 (64); ip->nhead = NET_PROTO_IP_TYPE_ICMP6; ip->hop = 0xff; memcpy (ip->ip_source, (void *) netif->ipv6, sizeof (net_ipv6)); memcpy (ip->ip_dest, (void *) dest, sizeof (net_ipv6)); /* icmp layer */ - proto_icmp_t *icmp = (proto_icmp_t *) kmalloc (sizeof (proto_icmp_t)+57); + proto_icmp_t *icmp = (proto_icmp_t *) kmalloc (sizeof (proto_icmp_t)+65); if (!icmp) return 0; - memset ((char *) icmp, 0, 56); + memset ((char *) icmp, 0, 64); icmp->type = NET_ICMP6_TYPE_PING_REQUEST; icmp->code = 0; - icmp->seq = 0; - icmp->checksum = checksum16_ipv6 (ip->ip_source, ip->ip_dest, icmp, sizeof (proto_icmp_t)+48, NET_PROTO_IP_TYPE_ICMP6); + icmp->seq = 0x3ff3; + + unsigned ret = 0; - unsigned ret = net_proto_ipv6_send (netif, packet, ip, (char *) icmp, sizeof (proto_icmp_t)+48); + icmp->checksum = checksum16_ipv6 (ip->ip_source, ip->ip_dest, icmp, sizeof (proto_icmp_t)+56, NET_PROTO_IP_TYPE_ICMP6); + + if (!tun6_addr_get ()) + ret = net_proto_ipv6_send (netif, packet, ip, (char *) icmp, sizeof (proto_icmp_t)+56); + else /* tunnel mode */ + ret = net_proto_tun6_send (netif, packet, ip, (char *) icmp, sizeof (proto_icmp_t)+56); kfree (icmp); kfree (ip); @@ -221,11 +258,17 @@ unsigned net_proto_icmp6_reply (netif_t *netif, packet_t *packet, proto_ipv6_t * buf_icmp[l+len] = '\0'; + unsigned ret = 0; + /* calculate checksum and put it to icmp header */ proto_icmp_t *icmp_ = (proto_icmp_t *) buf_icmp; + icmp_->checksum = checksum16_ipv6 (ip->ip_source, ip->ip_dest, buf_icmp, len+l, NET_PROTO_IP_TYPE_ICMP6); - unsigned ret = net_proto_ipv6_send (netif, packet, ip, buf_icmp, len+l); + if (!tun6_addr_get ()) + ret = net_proto_ipv6_send (netif, packet, ip, buf_icmp, len+l); + else + ret = net_proto_tun6_send (netif, packet, ip, buf_icmp, len+l); kfree (buf_icmp); diff --git a/kernel/core/net/if.c b/kernel/core/net/if.c index 4fbb922..69a7210 100644 --- a/kernel/core/net/if.c +++ b/kernel/core/net/if.c @@ -23,6 +23,7 @@ #include #include #include +#include netif_t netif_list; @@ -125,6 +126,11 @@ void iflist_display () printf ("\tEthernet IP address:\t"); net_proto_ip_print (netif->ip); printf ("\n\t\t\t\t"); net_proto_ipv6_print (netif->ipv6); printf ("\n\tGateway IP address:\t"); net_proto_ip_print (netif->gw); + + if (tun6_addr_get ()) { + printf ("\n\tTunnel IP address:\t::"); net_proto_ip_print (tun6_addr_get ()); + } + printf ("\n"); } } diff --git a/kernel/core/net/ip.c b/kernel/core/net/ip.c index e30d376..a28375a 100644 --- a/kernel/core/net/ip.c +++ b/kernel/core/net/ip.c @@ -17,6 +17,7 @@ */ +#include #include #include #include @@ -75,8 +76,10 @@ net_ipv4 net_proto_ip_convert (char *ip) i ++; } - if (g != 3) + if (g != 3) { + kfree (str); return 0; + } a = atoi (str); b = atoi (str+h[0]); @@ -155,6 +158,10 @@ unsigned net_proto_ip_handler (packet_t *packet, char *buf, unsigned len) return net_proto_udp_handler (packet, ip, buf+head_len, len-head_len); case NET_PROTO_IP_TYPE_ICMP: return net_proto_icmp_handler (packet, ip, buf+head_len, len-head_len); +#ifdef CONFIG_PROTO_TUN6 + case NET_PROTO_IP_TYPE_TUN6: + return net_proto_tun6_handler (packet, ip, buf+head_len, len-head_len); +#endif } return 0; diff --git a/kernel/core/net/ipv6.c b/kernel/core/net/ipv6.c index 89e7ca2..1f18fd8 100644 --- a/kernel/core/net/ipv6.c +++ b/kernel/core/net/ipv6.c @@ -72,57 +72,56 @@ unsigned net_proto_ipv6_cmp (net_ipv6 ip, net_ipv6 ip2) return 1; } -/*net_ipv4 net_proto_ipv6_convert (char *ip) +unsigned net_proto_ipv6_convert (net_ipv6 ipv6, char *ip) { - if (!ip) - return 0; - - unsigned char a = 0; - unsigned char b = 0; - unsigned char c = 0; - unsigned char d = 0; - - unsigned g = 0; + unsigned short a; + unsigned short b; + unsigned short c; + unsigned short d; + unsigned short e; + unsigned short f; + unsigned short g; + unsigned short h; + + unsigned j = 0; unsigned i = 0; unsigned y = strlen (ip); if (!y) return 0; - char *str = (char *) kmalloc (sizeof (char) * (y + 1)); - - if (!str) - return 0; - - memcpy (str, ip, y); - str[y] = '\0'; - - unsigned h[4]; + unsigned k[8]; while (i < y) { - if (str[i] == '.') { - str[i] = '\0'; - h[g] = i+1; - g ++; + if (ip[i] == ':') { + ip[i] = '\0'; + k[j] = i+1; + j ++; } i ++; } - if (g != 3) + if (j != 7) return 0; - - a = atoi (str); - b = atoi (str+h[0]); - c = atoi (str+h[1]); - d = atoi (str+h[2]); - kfree (str); + char *endptr; + + a = strtol (ip, &endptr, 16); + b = strtol (ip+k[0], &endptr, 16); + c = strtol (ip+k[1], &endptr, 16); + d = strtol (ip+k[2], &endptr, 16); + e = strtol (ip+k[3], &endptr, 16); + f = strtol (ip+k[4], &endptr, 16); + g = strtol (ip+k[5], &endptr, 16); + h = strtol (ip+k[6], &endptr, 16); - return NET_IPV4_TO_ADDR (a, b, c, d); + NET_IPV6_TO_ADDR (ipv6, a, b, c, d, e, f, g, h); + + return 1; } -unsigned net_proto_ip_convert2 (net_ipv4 ip, char *ip_addr) +/*unsigned net_proto_ip_convert2 (net_ipv4 ip, char *ip_addr) { if (!ip_addr) return 0; @@ -135,20 +134,20 @@ unsigned net_proto_ip_convert2 (net_ipv4 ip, char *ip_addr) sprintf (ip_addr, "%d.%d.%d.%d", a, b, c, d); return 1; -} +}*/ unsigned net_proto_ipv6_network (net_ipv6 ip) { - unsigned char a = (unsigned char) ip; + unsigned short a = (unsigned short) swap16 (ip[0]); - if (a == 192 || a == 10 || a == 127) + if (a == 0xfc00 || a == 0xfc02) return 0; else return 1; return 0; -}*/ +} unsigned net_proto_ipv6_send (netif_t *netif, packet_t *packet, proto_ipv6_t *ip, char *buf, unsigned len) { @@ -177,7 +176,7 @@ unsigned net_proto_ipv6_handler (packet_t *packet, char *buf, unsigned len) { proto_ipv6_t *ip = (proto_ipv6_t *) buf; - /* ipv6 provide directly length of data - peyload length */ + /* ipv6 provide directly length of data - payload length */ unsigned data_len = swap16 (ip->pl_len); //printf ("ipv6 -> 0x%x\n", ip->nhead); diff --git a/kernel/core/net/ndp.c b/kernel/core/net/ndp.c index 0f0b297..3381b95 100644 --- a/kernel/core/net/ndp.c +++ b/kernel/core/net/ndp.c @@ -27,6 +27,7 @@ #include #include #include +#include #include ndp_cache_t ndp_cache_list; diff --git a/kernel/core/net/packet.c b/kernel/core/net/packet.c index b9b8089..33e341c 100644 --- a/kernel/core/net/packet.c +++ b/kernel/core/net/packet.c @@ -17,6 +17,7 @@ */ +#include #include #include #include @@ -71,12 +72,16 @@ unsigned net_packet_handler (char *buf, unsigned len) //printf ("net_packet->type: 0x%04x\n", swap16 (packet->type)); switch (packet->type) { +#ifdef CONFIG_PROTO_IPV4 case NET_PACKET_TYPE_IPV4: return net_proto_ip_handler (packet, buf+sizeof (packet_t), len-sizeof (packet_t)); +#endif case NET_PACKET_TYPE_ARP: return net_proto_arp_handler (packet, buf+sizeof (packet_t), len-sizeof (packet_t)); +#ifdef CONFIG_PROTO_IPV6 case NET_PACKET_TYPE_IPV6: return net_proto_ipv6_handler (packet, buf+sizeof (packet_t), len-sizeof (packet_t)); +#endif } return 1; @@ -147,6 +152,9 @@ unsigned init_packet () if (!init_net_proto_dns ()) return 0; + if (!init_net_proto_tun6 ()) + return 0; + /* start new task/thread for network core */ task_netcore = (task_t *) task_create ("netcore", (unsigned) task_net_packet, 255); diff --git a/kernel/core/net/tcp6.c b/kernel/core/net/tcp6.c index dc9380c..abc5380 100644 --- a/kernel/core/net/tcp6.c +++ b/kernel/core/net/tcp6.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -334,7 +335,7 @@ int net_proto_tcp6_accept (int fd, sockaddr_in6 *addr, socklen_t *addrlen) /** TCP protocol * Hardcore code - syn, ack, psh, fin, etc :P */ -unsigned net_proto_tcp6_handler (packet_t *packet, proto_ipv6_t *ip, char *buf, unsigned len) +unsigned net_proto_tcp6_handler (packet_t *packet, proto_ipv6_t *ip, char *buf, unsigned len, unsigned flags) { proto_tcp_t *tcp = (proto_tcp_t *) buf; @@ -531,29 +532,59 @@ int net_proto_tcp6_write (netif_t *eth, net_ipv6 dest, proto_tcp_t *tcp, char *d return 0; mac_addr_t mac_dest; - unsigned get = ndp_cache_get (dest, &mac_dest); - if (!get) { - ndp_send_request (eth, dest); - - unsigned i = 0; - /* 200ms for waiting on NDP reply */ - while (i < 200) { - get = ndp_cache_get (dest, &mac_dest); - - if (get) - break; - - /* TODO: make better waiting for NDP reply */ - timer_wait (1); - - schedule (); + if (!tun6_addr_get ()) { + unsigned get = ndp_cache_get (dest, &mac_dest); + + if (!get) { + ndp_send_request (eth, dest); + + unsigned i = 0; + /* 200ms for waiting on NDP reply */ + while (i < 200) { + get = ndp_cache_get (dest, &mac_dest); - i ++; + if (get) + break; + + /* TODO: make better waiting for NDP reply */ + timer_wait (1); + + schedule (); + + i ++; + } + + if (!get) + return 0; + } + } else { + /* IPv6 tunnel stuff */ + net_ipv4 tunnel = tun6_addr_get (); + unsigned get = arp_cache_get (tunnel, &mac_dest); + + if (!get) { + arp_send_request (eth, tunnel); + + unsigned i = 0; + /* 100ms for waiting on ARP reply */ + while (i < 100) { + get = arp_cache_get (tunnel, &mac_dest); + + if (get) + break; + + /* TODO: make better waiting for ARP reply */ + timer_wait (1); + + schedule (); + + i ++; + } + + if (!get) + return 0; } - - if (!get) - return 0; } /* packet header */ @@ -599,10 +630,15 @@ int net_proto_tcp6_write (netif_t *eth, net_ipv6 dest, proto_tcp_t *tcp, char *d /* calculate checksum and put it to tcp header */ proto_tcp_t *tcp_ = (proto_tcp_t *) buf_tcp; + unsigned ret = 0; + tcp_->checksum = checksum16_ipv6 (eth->ipv6, dest, buf_tcp, l+len, NET_PROTO_IP_TYPE_TCP6); /* send tcp header+data to ip layer */ - unsigned ret = net_proto_ipv6_send (eth, packet, ip, (char *) buf_tcp, l+len); + if (!tun6_addr_get ()) + ret = net_proto_ipv6_send (eth, packet, ip, (char *) buf_tcp, l+len); + else + ret = net_proto_tun6_send (eth, packet, ip, (char *) buf_tcp, l+len); kfree (buf_tcp); kfree (ip); diff --git a/kernel/core/net/tun6.c b/kernel/core/net/tun6.c new file mode 100644 index 0000000..cf25e00 --- /dev/null +++ b/kernel/core/net/tun6.c @@ -0,0 +1,122 @@ +/* + * ZeX/OS + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +net_ipv4 tun6_ip; + +#define DEFAULT_TUN6_ADDRESS NET_IPV4_TO_ADDR (216,66,80,30) + + +unsigned tun6_addr (net_ipv4 tun6) +{ + tun6_ip = tun6; + + return 1; +} + +unsigned tun6_addr_get () +{ + return tun6_ip; +} + +unsigned net_proto_tun6_send (netif_t *netif, packet_t *packet, proto_ipv6_t *ip, char *buf, unsigned len) +{ + char *buf_ip = (char *) kmalloc ((len + 1 + sizeof (proto_ipv6_t))); + + if (!buf_ip) + return 0; + + unsigned l = sizeof (proto_ipv6_t); + + /* put ip header and buf data to one buffer */ + memcpy (buf_ip, (char *) ip, l); + memcpy (buf_ip+l, buf, len); + + buf_ip[l+len] = '\0'; + + + packet->type = NET_PACKET_TYPE_IPV4; + + /* ip layer */ + proto_ip_t *ipv4 = (proto_ip_t *) kmalloc (sizeof (proto_ip_t)); + + if (!ipv4) + return 0; + + /* there are some fixed values - yeah it is horrible */ + ipv4->ver = 4; + ipv4->head_len = 5; + + ipv4->flags = 0; + ipv4->frag = 0; + ipv4->ttl = 64; + ipv4->checksum = 0; + ipv4->proto = NET_PROTO_IP_TYPE_TUN6; + ipv4->ip_source = netif->ip; + ipv4->ip_dest = tun6_addr_get (); + + /* calculate total length of packet (ipv6/ip) */ + unsigned i = ipv4->head_len * 4; + ipv4->total_len = swap16 (i+l+len); + + unsigned ret = net_proto_ip_send (netif, packet, ipv4, buf_ip, l+len); + + kfree (ipv4); + kfree (buf_ip); + + return ret; +} + +unsigned net_proto_tun6_handler (packet_t *packet, proto_ip_t *ip, char *buf, unsigned len) +{ + proto_ipv6_t *ipv6 = (proto_ipv6_t *) buf; + + /* ipv6 provide directly length of data - payload length */ + unsigned data_len = swap16 (ipv6->pl_len); + + printf ("tun6 -> 0x%x\n", ipv6->nhead); + + switch (ipv6->nhead) { + case NET_PROTO_IP_TYPE_TCP6: + return net_proto_tcp6_handler (packet, ipv6, buf+sizeof (proto_ipv6_t), data_len); + case NET_PROTO_IP_TYPE_UDP6: + return net_proto_udp6_handler (packet, ipv6, buf+sizeof (proto_ipv6_t), data_len); + case NET_PROTO_IP_TYPE_ICMP6: + return net_proto_icmp6_handler (packet, ipv6, buf+sizeof (proto_ipv6_t), data_len); + } + + return 0; +} + +unsigned init_net_proto_tun6 () +{ + tun6_addr (0); + + return 1; +} diff --git a/kernel/core/net/udp6.c b/kernel/core/net/udp6.c index 3e0865e..5315645 100644 --- a/kernel/core/net/udp6.c +++ b/kernel/core/net/udp6.c @@ -333,29 +333,58 @@ int net_proto_udp6_write (proto_udp6_conn_t *conn, char *data, unsigned len) return 0; mac_addr_t mac_dest; - unsigned get = arp_cache_get (conn->ip_dest, &mac_dest); - - if (!get) { - arp_send_request (conn->netif, conn->ip_dest); - - unsigned i = 0; - /* 100ms for waiting on ARP reply */ - while (i < 100) { - get = arp_cache_get (conn->ip_dest, &mac_dest); - - if (get) - break; - - /* TODO: make better waiting for ARP reply */ - timer_wait (1); - - schedule (); + if (!tun6_addr_get ()) { + unsigned get = ndp_cache_get (conn->ip_dest, &mac_dest); + + if (!get) { + ndp_send_request (conn->netif, conn->ip_dest); - i ++; + unsigned i = 0; + /* 100ms for waiting on ARP reply */ + while (i < 100) { + get = ndp_cache_get (conn->ip_dest, &mac_dest); + + if (get) + break; + + /* TODO: make better waiting for ARP reply */ + timer_wait (1); + + schedule (); + + i ++; + } + + if (!get) + return 0; + } + } else { + /* IPv6 tunnel stuff */ + net_ipv4 tunnel = tun6_addr_get (); + unsigned get = arp_cache_get (tunnel, &mac_dest); + + if (!get) { + arp_send_request (conn->netif, tunnel); + + unsigned i = 0; + /* 100ms for waiting on ARP reply */ + while (i < 100) { + get = arp_cache_get (tunnel, &mac_dest); + + if (get) + break; + + /* TODO: make better waiting for ARP reply */ + timer_wait (1); + + schedule (); + + i ++; + } + + if (!get) + return 0; } - - if (!get) - return 0; } /* packet header */ @@ -415,8 +444,13 @@ int net_proto_udp6_write (proto_udp6_conn_t *conn, char *data, unsigned len) proto_udp_t *udp_ = (proto_udp_t *) buf_udp; udp_->checksum = checksum16_ipv6 (conn->netif->ipv6, conn->ip_dest, buf_udp, 8 + len, NET_PROTO_IP_TYPE_UDP6); + unsigned ret = 0; + /* send udp header+data to ip layer */ - unsigned ret = net_proto_ipv6_send (conn->netif, packet, ip, (char *) buf_udp, 8 + len); + if (!tun6_addr_get ()) + ret = net_proto_ipv6_send (conn->netif, packet, ip, (char *) buf_udp, 8 + len); + else + ret = net_proto_tun6_send (conn->netif, packet, ip, (char *) buf_udp, 8 + len); kfree (buf_udp); kfree (udp); diff --git a/kernel/core/vfs.c b/kernel/core/vfs.c index 9fa5cdd..a19d82c 100755 --- a/kernel/core/vfs.c +++ b/kernel/core/vfs.c @@ -30,16 +30,17 @@ extern unsigned int fd_count; vfs_t *vfs_list_findbymp (char *mountpoint) { - char mdir[64]; + char mdir[128]; char pwd[64]; strcpy (pwd, (char *) env_get ("PWD")); + unsigned l = strlen (pwd); vfs_t *vfs; for (vfs = vfs_list.next; vfs != &vfs_list; vfs = vfs->next) { - if (strcmp (pwd, vfs->mountpoint)) + if (strncmp (pwd, vfs->mountpoint, l)) continue; - sprintf (mdir, "/%s/", vfs->name); + sprintf (mdir, "%s%s/", vfs->mountpoint, vfs->name); if (!strcmp (mdir, mountpoint)) return vfs; diff --git a/kernel/include/net/dns.h b/kernel/include/net/dns.h index e9b734d..fe427b9 100644 --- a/kernel/include/net/dns.h +++ b/kernel/include/net/dns.h @@ -41,6 +41,7 @@ typedef struct proto_dns_t { unsigned short add; } __PACKED__ proto_dns_t; -unsigned init_net_proto_dns (); +/* externs */ +extern unsigned init_net_proto_dns (); #endif diff --git a/kernel/include/net/ip.h b/kernel/include/net/ip.h index c06e5c2..03d8c0d 100644 --- a/kernel/include/net/ip.h +++ b/kernel/include/net/ip.h @@ -34,6 +34,10 @@ typedef unsigned short net_ipv6[8]; #define NET_PROTO_IP_TYPE_TCP6 0x6 #define NET_PROTO_IP_TYPE_UDP 0x11 #define NET_PROTO_IP_TYPE_UDP6 0x11 +#define NET_PROTO_IP_TYPE_TUN6 0x29 + +#define NET_PROTO_IP_FLAG_TUNNEL 0x80 + typedef struct proto_ip_t { unsigned char head_len:4; diff --git a/kernel/lib/stdio/fclose.c b/kernel/include/net/tun.h similarity index 78% copy from kernel/lib/stdio/fclose.c copy to kernel/include/net/tun.h index 7f93c34..c40888c 100644 --- a/kernel/lib/stdio/fclose.c +++ b/kernel/include/net/tun.h @@ -1,6 +1,6 @@ /* * ZeX/OS - * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,15 +16,11 @@ * along with this program. If not, see . */ -#include +#ifndef _TUN_H +#define _TUN_H -int fclose (FILE *file) -{ - if (!file) - return 0; +/* externs */ +extern unsigned tun6_addr_get (); +extern unsigned init_net_proto_tun6 (); - free (file); - - return 1; -} - +#endif diff --git a/kernel/include/stdio.h b/kernel/include/stdio.h index fe421ab..c7b04cc 100755 --- a/kernel/include/stdio.h +++ b/kernel/include/stdio.h @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,5 +24,7 @@ extern void puts (unsigned char *text); extern void printf (const char *fmt, ...); extern int sprintf (char *buffer, const char *fmt, ...); +extern int open (const char *pathname, int flags); +extern int close (int fd); #endif diff --git a/kernel/include/system.h b/kernel/include/system.h index 2a21bb6..3e21473 100755 --- a/kernel/include/system.h +++ b/kernel/include/system.h @@ -118,6 +118,9 @@ extern int init (); extern void *malloc (unsigned size); extern void *realloc(void *blk, unsigned size); extern void free (void *blk); +extern void *kmalloc (unsigned size); +extern void *krealloc(void *blk, unsigned size); +extern void kfree (void *blk); extern unsigned int init_mm (); diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 483ac9a..3707e00 100755 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -19,7 +19,7 @@ ifeq ($(ARCH),x86_64) LD=ld -m elf_x86_64 endif -OBJS =arch/main/boot/start.o core/main.o core/init.o core/console.o core/commands.o core/mm/kmem.o core/mm/dlmem.o core/mm/vmem.o core/mm/pmem.o core/env.o core/elf.o core/dev.o core/vfs.o core/fs.o core/user.o core/sched.o core/proc.o core/tty.o core/partition.o core/module.o core/spinlock.o core/mutex.o core/smp.o core/net/socket.o core/net/ips.o core/net/eth.o core/net/if.o core/net/arp.o core/net/packet.o core/net/tcp.o core/net/tcp6.o core/net/ip.o core/net/ipv6.o core/net/icmp.o core/net/icmp6.o core/net/ndp.o core/net/checksum.o core/net/udp.o core/net/udp6.o core/net/dns.o drivers/char/video/video.o drivers/char/video/vesa.o drivers/char/video/gtext.o drivers/char/video/bga.o drivers/char/kbd/kbd.o drivers/char/rs232/rs232.o drivers/char/sound/speaker.o drivers/block/floppy.o drivers/block/drive.o drivers/fs/fat.o drivers/fs/fat16.o drivers/fs/zexfs.o drivers/fs/ext2.o drivers/fs/isofs.o drivers/bus/pci/pci.o drivers/bus/usb/usb.o drivers/net/pcnet32/pcnet32.o drivers/net/rtl8029/rtl8029.o drivers/net/rtl8139/rtl8139.o drivers/char/mouse/ps2.o utils/fs/ls.o utils/fs/cat.o utils/fs/exec.o utils/fs/cd.o utils/fs/mount.o utils/fs/mkdir.o utils/fs/fdisk.o utils/net/tftp.o +OBJS =arch/main/boot/start.o core/main.o core/init.o core/console.o core/commands.o core/mm/kmem.o core/mm/dlmem.o core/mm/vmem.o core/mm/pmem.o core/env.o core/elf.o core/dev.o core/vfs.o core/fs.o core/user.o core/sched.o core/proc.o core/tty.o core/partition.o core/module.o core/spinlock.o core/mutex.o core/smp.o core/net/socket.o core/net/ips.o core/net/eth.o core/net/if.o core/net/arp.o core/net/packet.o core/net/tcp.o core/net/tcp6.o core/net/ip.o core/net/ipv6.o core/net/icmp.o core/net/icmp6.o core/net/ndp.o core/net/checksum.o core/net/udp.o core/net/udp6.o core/net/dns.o core/net/tun6.o drivers/char/video/video.o drivers/char/video/vesa.o drivers/char/video/gtext.o drivers/char/video/bga.o drivers/char/kbd/kbd.o drivers/char/rs232/rs232.o drivers/char/sound/speaker.o drivers/block/floppy.o drivers/block/drive.o drivers/fs/fat.o drivers/fs/fat16.o drivers/fs/zexfs.o drivers/fs/ext2.o drivers/fs/isofs.o drivers/bus/pci/pci.o drivers/bus/usb/usb.o drivers/net/pcnet32/pcnet32.o drivers/net/rtl8029/rtl8029.o drivers/net/rtl8139/rtl8139.o drivers/char/mouse/ps2.o utils/fs/ls.o utils/fs/cat.o utils/fs/exec.o utils/fs/cd.o utils/fs/mount.o utils/fs/mkdir.o utils/fs/fdisk.o utils/net/tftp.o ifneq ($(strip $(wildcard .config)),) @@ -39,7 +39,7 @@ clean: $(Q)make clean -C arch/main $(Q)rm include/arch $(Q)rm -f *.o kernel.bin .directory .kconfig.d .tmpconfig.h .config.old arch/main $(OBJS) - $(Q)rm -rf build/main/utils build/main build/utils + $(Q)rm -rf build/main/utils build/main/config.h build/main/build.h build/main build/utils @printf " CLEAN\n"; # implicit rules @@ -87,6 +87,7 @@ core/net/if.o: core/net/if.c $(MAKEDEP) core/net/arp.o: core/net/arp.c $(MAKEDEP) core/net/packet.o: core/net/packet.c $(MAKEDEP) core/net/tcp.o: core/net/tcp.c $(MAKEDEP) +core/net/tcp6.o: core/net/tcp6.c $(MAKEDEP) core/net/ip.o: core/net/ip.c $(MAKEDEP) core/net/ipv6.o: core/net/ipv6.c $(MAKEDEP) core/net/icmp.o: core/net/icmp.c $(MAKEDEP) @@ -96,6 +97,7 @@ core/net/checksum.o: core/net/checksum.c $(MAKEDEP) core/net/udp.o: core/net/udp.c $(MAKEDEP) core/net/udp6.o: core/net/udp6.c $(MAKEDEP) core/net/dns.o: core/net/dns.c $(MAKEDEP) +core/net/tun6.o: core/net/tun6.c $(MAKEDEP) # drivers drivers/char/video.o: drivers/char/video/video.c $(MAKEDEP) drivers/char/vesa.o: drivers/char/video/vesa.c $(MAKEDEP) diff --git a/kernel/lib/mm/mem.c b/kernel/lib/mm/mem.c index 750d01d..dcbc510 100755 --- a/kernel/lib/mm/mem.c +++ b/kernel/lib/mm/mem.c @@ -44,7 +44,7 @@ typedef struct _malloc /* Turbo C DJGPP */ static char *g_heap_bot, *g_kbrk, *g_heap_top; /***************************************************************************** *****************************************************************************/ -static void dump_heap (void) +/*static void dump_heap (void) { unsigned blks_used = 0, blks_free = 0; size_t bytes_used = 0, bytes_free = 0; @@ -80,7 +80,7 @@ static void dump_heap (void) if(total != g_kbrk - g_heap_bot) DPRINT ("*** some heap memory is not accounted for\n"); -} +}*/ /***************************************************************************** POSIX sbrk() looks like this void *sbrk(int incr); diff --git a/kernel/lib/stdio/delay.c b/kernel/lib/stdio/delay.c index 08a1a5b..a0c53e8 100755 --- a/kernel/lib/stdio/delay.c +++ b/kernel/lib/stdio/delay.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,21 +54,6 @@ /**************************************************************************/ /* - * The delay function: - * Have a look at this function before you look at the calibration code. - * Basically, delay_count is the number you have to count to in order to - * kill 1ms. delay() takes the amount of milliseconds to delay as - * parameter. - * - * The goal of the rest of this code is to determine what delay_count *is* - * for your machine. - * - * Keep delay_count initialised to 1. We'll need that later. - */ - -static unsigned long delay_count = 1; - -/* * When I was testing the delay code, I notice that the calibration we use * is very delicate. Originally, I had inlined the delay for() loops into * the delay() and calibrateDelayLoop() functions, but this doesn't work. @@ -81,7 +67,7 @@ static unsigned long delay_count = 1; * calibration without it losing its finesse afterwards. */ -void __delay(loops) +void __delay(unsigned long loops) { unsigned long c; for (c = 0; c < loops; c ++); diff --git a/kernel/lib/stdio/fclose.c b/kernel/lib/stdio/fclose.c index 7f93c34..e7fa1b9 100644 --- a/kernel/lib/stdio/fclose.c +++ b/kernel/lib/stdio/fclose.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,13 +18,14 @@ */ #include +#include int fclose (FILE *file) { if (!file) return 0; - free (file); + kfree (file); return 1; } diff --git a/kernel/lib/stdio/fgets.c b/kernel/lib/stdio/fgets.c index 1ed9754..5765438 100644 --- a/kernel/lib/stdio/fgets.c +++ b/kernel/lib/stdio/fgets.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +23,7 @@ char *fgets (char *string, int n, FILE *file) { - if (n > file->e) + if (n > (int) file->e) n = file->e; memcpy (string, file->ptr, n); diff --git a/kernel/lib/stdio/fopen.c b/kernel/lib/stdio/fopen.c index 8c1fc13..5d71367 100644 --- a/kernel/lib/stdio/fopen.c +++ b/kernel/lib/stdio/fopen.c @@ -18,6 +18,7 @@ #include +#include #include extern fd_t fd_list; @@ -26,7 +27,7 @@ static fd_t *getbyfd (int id) { fd_t *fd; for (fd = fd_list.next; fd != &fd_list; fd = fd->next) { - if (fd->id == id) + if (fd->id == (unsigned) id) return fd; } diff --git a/kernel/lib/stdio/kprintf.c b/kernel/lib/stdio/kprintf.c index b627be2..810458e 100755 --- a/kernel/lib/stdio/kprintf.c +++ b/kernel/lib/stdio/kprintf.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +18,7 @@ */ +#include #include #include #include <_printf.h> @@ -54,4 +56,4 @@ void DPRINT (const char *fmt, ...) va_end (args); putch ('\n'); -} \ No newline at end of file +} diff --git a/kernel/lib/stdio/open.c b/kernel/lib/stdio/open.c index b32003c..44982e4 100644 --- a/kernel/lib/stdio/open.c +++ b/kernel/lib/stdio/open.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,7 +40,8 @@ int open (const char *pathname, int flags) return 0; } - fd_t *fd = malloc (sizeof (fd_t)); + fd_t *fd = kmalloc (sizeof (fd_t)); + if (!fd) return 0; @@ -56,10 +58,8 @@ int open (const char *pathname, int flags) return 0; } - while (strlen (dir[i].name)) - { - if (!strncmp (pathname, dir[i].name, fi_len)) - { + while (strlen (dir[i].name)) { + if (!strncmp (pathname, dir[i].name, fi_len)) { char block[512]; p->fs->handler (FS_ACT_READ, FS_ARG_FILE, block, i, fd->e); @@ -79,6 +79,7 @@ int open (const char *pathname, int flags) return fd->id; } + i++; } diff --git a/kernel/lib/stdio/printf.c b/kernel/lib/stdio/printf.c index cb5d906..85d58bf 100755 --- a/kernel/lib/stdio/printf.c +++ b/kernel/lib/stdio/printf.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +17,7 @@ * along with this program. If not, see . */ - +#include #include #include #include <_printf.h> diff --git a/kernel/lib/stdio/puts.c b/kernel/lib/stdio/puts.c index b51c6a3..149684b 100755 --- a/kernel/lib/stdio/puts.c +++ b/kernel/lib/stdio/puts.c @@ -1,6 +1,7 @@ /* * ZeX/OS - * Copyright (C) 2007,2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +25,8 @@ void puts (unsigned char *text) { int i; - - for (i = 0; i < strlen(text); i++) + int l = strlen ((char *) text); + + for (i = 0; i < l; i ++) tty_putch (text[i]); } diff --git a/kernel/lib/string/strcat.c b/kernel/lib/string/strcat.c index 90f38be..cff1aa1 100755 --- a/kernel/lib/string/strcat.c +++ b/kernel/lib/string/strcat.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +20,11 @@ char *strcat (unsigned char *s, const unsigned char *add) { - register char *ret = s; - while (*s) s++; + register char *ret = (char *) s; + + while (*s) + s++; + while ((*s++ = *add++) != 0); - return ret; + return ret; } diff --git a/kernel/lib/unistd/fcntl.c b/kernel/lib/unistd/fcntl.c index acc51c3..1f61e13 100755 --- a/kernel/lib/unistd/fcntl.c +++ b/kernel/lib/unistd/fcntl.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include extern unsigned int fd_count; diff --git a/libc/unistd/dup.c b/libc/unistd/dup.c index 97b515d..3dc7e8c 100755 --- a/libc/unistd/dup.c +++ b/libc/unistd/dup.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +18,7 @@ */ #include +#include int dup (int fildes) { diff --git a/libx/cursor/xcursor.c b/libx/cursor/xcursor.c index 60f48fc..80c618f 100755 --- a/libx/cursor/xcursor.c +++ b/libx/cursor/xcursor.c @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) + * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,7 +100,7 @@ static unsigned xcursor_serialmouse_init () return 0; } -static void ps2mouse_handler (void *r) +/*static void ps2mouse_handler (void *r) { while (inportb (0x64) == 0x02) // Wait until on port 0x64 isnĀ“t 02h schedule (); @@ -141,7 +142,7 @@ static void ps2mouse_handler (void *r) cursor_x = (vgafb_res_x-1); cursor_state = (b1 >> 4) & 3; -} +}*/ static unsigned xcursor_ps2mouse_init () { -- 2.11.4.GIT