summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-27 01:21:33 +0200
committerMiguel <m.i@gmx.at>2018-09-27 01:21:33 +0200
commitc7bf9cc575dea15ecc8780afd34ffb3503f3249b (patch)
treef470f78f6abe7d8af1c7e835fbbaa9bec13a9cdf /net
parentc7199cdb8b088b1b1d243aabfbd1c831bdae9637 (diff)
try to isolate netstack to library
Diffstat (limited to 'net')
-rw-r--r--net/Makefile92
-rw-r--r--net/eth.c2
-rw-r--r--net/icmp.c6
-rw-r--r--net/net_sys.h7
-rw-r--r--net/udp.h2
5 files changed, 103 insertions, 6 deletions
diff --git a/net/Makefile b/net/Makefile
new file mode 100644
index 0000000..b8ab2b6
--- /dev/null
+++ b/net/Makefile
@@ -0,0 +1,92 @@
+
+ ##############
+ # Fool Stack #
+ ##############
+
+############ compiler ############
+
+#use our cross compiler
+CC=i686-foolos-gcc
+AS=i686-foolos-as
+
+#sorry just this
+CC=i686-elf-gcc
+AS=i686-elf-as
+
+############ compiler flags ############
+
+
+#https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
+
+CFLAGS=
+#CFLAGS+=-fvar-tracking
+#CFLAGS+=-DGIT_REVISION=\"$(GIT_REVISION)\"
+CFLAGS+=-ffreestanding # do we need this if using own compiler?
+CFLAGS+=-nostdlib
+#CFLAGS+=-Og
+CFLAGS+=-O0
+#CFLAGS+=-I.
+#CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include/
+#CFLAGS+=-I./asm
+#CFLAGS+=-I./kernel
+#CFLAGS+=-I./driver
+#CFLAGS+=-I./fs
+CFLAGS+=-gstabs
+
+#CFLAGS+=-fstack-protector-all
+#CFLAGS+=-fno-zero-initialized-in-bss
+#CFLAGS+=-fdata-sections -ffunction-sections
+
+#CFLAGS+= -w # disable all warnings
+#CFLAGS+= -Wimplicit-function-declaration
+CFLAGS+= -Wall
+#CFLAGS+= -Wextra
+#CFLAGS+= -pedantic
+CFLAGS+= -Werror
+CFLAGS+= -Werror=implicit-function-declaration
+
+CFLAGS+= -Wno-unused-variable
+CFLAGS+= -Wno-unused-function
+CFLAGS+= -Wno-int-conversion
+CFLAGS+= -Wno-implicit-int
+CFLAGS+= -Wno-incompatible-pointer-types
+CFLAGS+= -Wno-discarded-qualifiers
+CFLAGS+= -Wno-unused-but-set-variable
+
+#CFLAGS+ = -Wall -Wextra -std=c89 -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition
+
+######## linker flags ####################
+LDFLAGS=
+LDLIBS+=-lgcc
+
+########## assembler flags #################
+ASFLAGS=
+ASFLAGS+=-gstabs
+
+########## verbosity ##################3
+#V = 0
+#CC = @echo "Compiling (i686-elf-gcc) $<..."; i686-elf-gcc
+#AS = @echo "Assembling (i686-elf-as) $<..."; i686-elf-as
+#CC_1 = $(CCC)
+#CC = $(CC_$(V))
+
+############ source and object files and their deps ############
+
+#source files
+SOURCES=
+SOURCES+=$(wildcard *.c)
+
+#derive object files
+OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
+
+#derive and include deps
+DEPS=$(patsubst %.c, %.d, $(SOURCES))
+
+-include $(DEPS)
+
+tags:
+ @echo "Generating ctags..."; ctags --recurse=yes .
+
+clean:
+ @echo "Cleaning..."; rm -f *.d *.o tags
+
diff --git a/net/eth.c b/net/eth.c
index 780a89a..fedcda5 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -1,7 +1,7 @@
+#include "net_sys.h"
#include "inet.h"
#include "eth.h"
#include "netdev.h"
-#include "lib/string/string.h"
uint32_t eth_generic(struct netdev *dev, uint32_t ip, uint16_t type, uint8_t* pos,uint32_t *end)
{
diff --git a/net/icmp.c b/net/icmp.c
index d2e4de2..3c071dd 100644
--- a/net/icmp.c
+++ b/net/icmp.c
@@ -1,10 +1,8 @@
+#include "net_sys.h"
+
#include "inet.h"
#include "icmp.h"
#include "ipv4.h"
-#include "log.h"
-#include "kmalloc.h"
-
-#include "lib/string/string.h"
uint32_t icmp_generic(struct netdev *dev, uint32_t ip, uint8_t type, uint8_t* pos,uint8_t *end)
{
diff --git a/net/net_sys.h b/net/net_sys.h
new file mode 100644
index 0000000..a296b41
--- /dev/null
+++ b/net/net_sys.h
@@ -0,0 +1,7 @@
+/**
+ * @file
+ *
+ * this has to be provided and linked against the fool stack
+ */
+
+void* memcpy(void* restrict dstptr, const void* restrict srcptr, int size);
diff --git a/net/udp.h b/net/udp.h
index 2c30804..85aa248 100644
--- a/net/udp.h
+++ b/net/udp.h
@@ -1,5 +1,5 @@
-#include "netdev.h"
#include <stdint.h>
+#include "netdev.h"
struct udp_v4{
uint16_t src_port;