upgrade to newest metalsvm
This commit is contained in:
parent
f8b2a099c9
commit
7724b70d55
207 changed files with 773 additions and 2651 deletions
108
Makefile
108
Makefile
|
@ -1,108 +0,0 @@
|
|||
TOPDIR = $(shell pwd)
|
||||
ARCH = x86
|
||||
NAME = metalsvm
|
||||
LWIPDIRS = lwip/src/api lwip/src/core lwip/src/core/ipv4 lwip/src/netif
|
||||
DRIVERDIRS = drivers/net drivers/char
|
||||
KERNDIRS = libkern kernel mm fs arch/$(ARCH)/kernel arch/$(ARCH)/mm arch/$(ARCH)/scc $(LWIPDIRS) $(DRIVERDIRS)
|
||||
SUBDIRS = $(KERNDIRS)
|
||||
|
||||
CC_FOR_TARGET=i386-unknown-linux-gnu-gcc
|
||||
CXX_FOR_TARGET=i386-unknown-linux-gnu-g++
|
||||
GCC_FOR_TARGET=i386-unknown-linux-gnu-gcc
|
||||
AR_FOR_TARGET=i386-unknown-linux-gnu-ar
|
||||
AS_FOR_TARGET=i386-unknown-linux-gnu-as
|
||||
LD_FOR_TARGET=i386-unknown-linux-gnu-ld
|
||||
NM_FOR_TARGET=i386-unknown-linux-gnu-nm
|
||||
OBJDUMP_FOR_TARGET=i386-unknown-linux-gnu-objdump
|
||||
OBJCOPY_FOR_TARGET=i386-unknown-linux-gnu-objcopy
|
||||
RANLIB_FOR_TARGET=i386-unknown-linux-gnu-ranlib
|
||||
STRIP_FOR_TARGET=i386-unknown-linux-gnu-strip
|
||||
READELF_FOR_TARGET=i386-unknown-linux-gnu-readelf
|
||||
NASM = nasm
|
||||
EMU=qemu
|
||||
GDB=gdb
|
||||
|
||||
MAKE = make
|
||||
NASMFLAGS = -felf32 -g
|
||||
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include -I$(TOPDIR)/lwip/src/include -I$(TOPDIR)/lwip/src/include/ipv4 -I$(TOPDIR)/drivers
|
||||
# Compiler options for final code
|
||||
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fno-zero-initialized-in-bss -fno-builtin -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc $(INCLUDE)
|
||||
# Compiler options for debuuging
|
||||
#CFLAGS = -g -O -m32 -march=i586 -Wall -fno-zero-initialized-in-bss -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE)
|
||||
ARFLAGS = rsv
|
||||
RM = rm -rf
|
||||
LDFLAGS = -T link.ld -z max-page-size=4096 --defsym __BUILD_DATE=$(shell date +'%Y%m%d') --defsym __BUILD_TIME=$(shell date +'%H%M%S')
|
||||
STRIP_DEBUG = --strip-debug
|
||||
KEEP_DEBUG = --only-keep-debug
|
||||
|
||||
# Prettify output
|
||||
V = 0
|
||||
ifeq ($V,0)
|
||||
Q = @
|
||||
P = > /dev/null
|
||||
endif
|
||||
|
||||
default: all
|
||||
|
||||
all: newlib tools $(NAME).elf
|
||||
|
||||
newlib:
|
||||
$(MAKE) ARCH=$(ARCH) LDFLAGS="-m32" CFLAGS="-m32 -O2 -march=i586 " NASMFLAGS="$(NASMFLAGS)" CC_FOR_TARGET=$(CC_FOR_TARGET) \
|
||||
CXX_FOR_TARGET=$(CXX_FOR_TARGET) \
|
||||
GCC_FOR_TARGET=$(GCC_FOR_TARGET) \
|
||||
AR_FOR_TARGET=$(AR_FOR_TARGET) \
|
||||
AS_FOR_TARGET=$(AS_FOR_TARGET) \
|
||||
LD_FOR_TARGET=$(LD_FOR_TARGET) \
|
||||
NM_FOR_TARGET=$(NM_FOR_TARGET) \
|
||||
OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET) \
|
||||
OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) \
|
||||
RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET) \
|
||||
STRIP_FOR_TARGET=$(STRIP_FOR_TARGET) \
|
||||
READELF_FOR_TARGET=$(READELF_FOR_TARGET) -C newlib
|
||||
|
||||
tools:
|
||||
$(MAKE) -C tools
|
||||
|
||||
$(NAME).elf:
|
||||
$Q$(LD_FOR_TARGET) $(LDFLAGS) -o $(NAME).elf $^
|
||||
@echo [OBJCOPY] $(NAME).sym
|
||||
$Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $(NAME).elf $(NAME).sym
|
||||
@echo [OBJCOPY] $(NAME).elf
|
||||
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(NAME).elf
|
||||
|
||||
qemu: newlib tools $(NAME).elf
|
||||
qemu -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.elf -initrd tools/initrd.img
|
||||
|
||||
qemudbg: newlib tools $(NAME).elf
|
||||
qemu -S -s -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.elf -initrd tools/initrd.img
|
||||
|
||||
gdb: $(NAME).elf
|
||||
make qemudbg > /dev/null &
|
||||
$(GDB) -x script.gdb
|
||||
|
||||
clean:
|
||||
$Q$(RM) $(NAME).elf $(NAME).sym *~
|
||||
$Q$(MAKE) -C tools clean
|
||||
@echo Cleaned.
|
||||
|
||||
veryclean: clean
|
||||
$Q$(MAKE) -C newlib veryclean
|
||||
@echo Very cleaned
|
||||
|
||||
#depend:
|
||||
# for i in $(SUBDIRS); do $(MAKE) -k -C $$i depend; done
|
||||
|
||||
%.o : %.c
|
||||
@echo [CC] $@
|
||||
$Q$(CC_FOR_TARGET) -c -D__KERNEL__ $(CFLAGS) -o $@ $<
|
||||
@echo [DEP] $*.dep
|
||||
$Q$(CC_FOR_TARGET) -MF $*.dep -MT $*.o -MM $(CFLAGS) $<
|
||||
|
||||
|
||||
%.o : %.asm
|
||||
@echo [ASM] $@
|
||||
$Q$(NASM) $(NASMFLAGS) -o $@ $<
|
||||
|
||||
.PHONY: default all clean emu gdb newlib tools
|
||||
|
||||
include $(addsuffix /Makefile,$(SUBDIRS))
|
|
@ -155,6 +155,9 @@
|
|||
#define CRB_X5_Y3 0xf7000000
|
||||
#define CRB_OWN 0xf8000000
|
||||
|
||||
// FPGA registers
|
||||
#define FPGA_BASE 0xf9000000
|
||||
|
||||
// Symbol for RPC
|
||||
#define RPC_BASE 0xfb000000
|
||||
|
||||
|
|
|
@ -68,6 +68,13 @@ static inline void save_fpu_state(union fpu_state* state) {
|
|||
asm volatile ("fsave %0; fwait" : "=m"((*state).fsave));
|
||||
}
|
||||
|
||||
static inline void restore_fpu_state(union fpu_state* state) {
|
||||
if (has_fxsr())
|
||||
asm volatile ("fxrstor %0" :: "m"(state->fxsave));
|
||||
else
|
||||
asm volatile ("frstor %0" :: "m"(state->fsave));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -73,7 +73,7 @@ stublet:
|
|||
; clears the current pgd entry
|
||||
xor eax, eax
|
||||
mov cr3, eax
|
||||
; disable SSE support (TODO)
|
||||
; at this stage, we disable the SSE support
|
||||
mov eax, cr4
|
||||
and eax, 0xfffbf9ff
|
||||
mov cr4, eax
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
gdt_ptr_t gp;
|
||||
static tss_t task_state_segments[MAX_TASKS] __attribute__ ((aligned (PAGE_SIZE)));
|
||||
static unsigned char kstacks[MAX_TASKS][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE)));
|
||||
static unsigned char kstacks[MAX_TASKS][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE), section (".data")));
|
||||
// currently, our kernel has full access to the ioports
|
||||
static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0, 0}};
|
||||
unsigned char* default_stack_pointer = kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t);
|
||||
unsigned char* default_stack_pointer __attribute__ ((section (".data"))) = kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t);
|
||||
|
||||
/*
|
||||
* This is in start.asm. We use this to properly reload
|
||||
|
|
|
@ -196,11 +196,7 @@ static void fpu_handler(struct state *s)
|
|||
task->flags |= TASK_FPU_INIT;
|
||||
}
|
||||
|
||||
// restore the FPU context
|
||||
if (has_fxsr())
|
||||
asm volatile ("fxrstor %0" :: "m"(task->fpu.fxsave));
|
||||
else
|
||||
asm volatile ("frstor %0" :: "m"(task->fpu.fsave));
|
||||
restore_fpu_state(&task->fpu);
|
||||
task->flags |= TASK_FPU_USED;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
/** Global multiboot information structure pointer */
|
||||
multiboot_info_t* mb_info = NULL;
|
||||
multiboot_info_t* mb_info __attribute__ ((section (".data"))) = NULL;
|
||||
#endif
|
||||
|
||||
/** @brief initialization procedure for Multiboot information structure
|
||||
|
|
|
@ -733,6 +733,10 @@ int arch_paging_init(void)
|
|||
// map SCC's message passing buffers
|
||||
viraddr = map_region(MPB_X0_Y0, MPB_X0_Y0, (MPB_OWN-MPB_X0_Y0+16*1024*1024) >> PAGE_SHIFT, MAP_KERNEL_SPACE|MAP_MPE);
|
||||
kprintf("Map message passing buffers at 0x%x\n", viraddr);
|
||||
|
||||
// map the FPGA registers
|
||||
viraddr = map_region(FPGA_BASE, FPGA_BASE, 0x10000 >> PAGE_SHIFT, MAP_KERNEL_SPACE|MAP_NO_CACHE);
|
||||
kprintf("Map FPGA regsiters at 0x%x\n", viraddr);
|
||||
#endif
|
||||
|
||||
/* enable paging */
|
||||
|
|
|
@ -337,7 +337,7 @@ int RCCE_init(
|
|||
|
||||
RCCE_shmalloc_init(RC_SHM_BUFFER_START()+RCCE_SHM_BUFFER_offset ,RCCE_SHM_SIZE_MAX);
|
||||
#ifdef SHMDBG
|
||||
kprintf("\n%d:%s:%d: RCCE_SHM_BUFFER_offset, RCCE_SHM_SIZE_MAX: % x %x\n", RCCE_IAM,
|
||||
kprintf("\n%d:%s:%d: RCCE_SHM_BUFFER_offset, RCCE_SHM_SIZE_MAX: %x %x\n", RCCE_IAM,
|
||||
__FILE__,__LINE__,RCCE_SHM_BUFFER_offset ,RCCE_SHM_SIZE_MAX);
|
||||
#endif
|
||||
#else
|
||||
|
|
|
@ -132,6 +132,7 @@ int icc_init(void)
|
|||
|
||||
RCCE_barrier(&RCCE_COMM_WORLD);
|
||||
|
||||
#if 0
|
||||
kputs("RCCE test...\t");
|
||||
if (my_ue == 0)
|
||||
msg = 0x4711;
|
||||
|
@ -139,6 +140,7 @@ int icc_init(void)
|
|||
kprintf("successfull! (0x%x)\n", msg);
|
||||
else
|
||||
kprintf("failed! (0x%x)\n", msg);
|
||||
#endif
|
||||
|
||||
// reset INTR/LINT0 flag
|
||||
z = Z_PID(RC_COREID[my_ue]);
|
||||
|
@ -147,7 +149,7 @@ int icc_init(void)
|
|||
SetConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1), tmp);
|
||||
|
||||
// set interrupt handler (INTR/LINT0)
|
||||
irq_install_handler(124, intr_handler);
|
||||
//irq_install_handler(124, intr_handler);
|
||||
|
||||
kputs("Now, the SCC is initialized!\n");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
C_source := rtl8139.c mmnif.c
|
||||
C_source := rtl8139.c rckemac.c mmnif.c
|
||||
MODULE := drivers_net
|
||||
|
||||
include $(TOPDIR)/Makefile.inc
|
||||
|
|
|
@ -37,7 +37,11 @@
|
|||
#include <netif/etharp.h>
|
||||
#endif
|
||||
#include <net/rtl8139.h>
|
||||
#include <net/mmnif.h>
|
||||
#include <net/rckemac.h>
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
#include <asm/RCCE.h>
|
||||
#include <asm/RCCE_lib.h>
|
||||
#endif
|
||||
|
||||
void echo_init(void);
|
||||
void ping_init(void);
|
||||
|
@ -58,11 +62,12 @@ int lowlevel_init(void)
|
|||
|
||||
koutput_init();
|
||||
|
||||
//kprintf("Now, the BSS section (0x%x - 0x%x) is initialized.\n", (size_t) &bss_start, (size_t) &bss_end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if defined(CONFIG_LWIP) && defined(CONFIG_PCI)
|
||||
#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK))
|
||||
static tid_t netid;
|
||||
|
||||
int STDCALL network_task(void* arg)
|
||||
|
@ -74,10 +79,15 @@ int STDCALL network_task(void* arg)
|
|||
|
||||
kputs("Network task is started\n");
|
||||
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
/* Set network address variables */
|
||||
//IP4_ADDR(&gw, 192,168,1,254);
|
||||
//IP4_ADDR(&ipaddr, 192,168,1,100);
|
||||
//IP4_ADDR(&netmask, 255,255,255,0);
|
||||
IP4_ADDR(&gw, 192,168,4,254);
|
||||
IP4_ADDR(&ipaddr, 192,168,4,RCCE_ue()+1);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
/* Bring up the network interface */
|
||||
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, ethernet_input)) {
|
||||
#else
|
||||
/* Clear network address because we use DHCP to get an ip address */
|
||||
IP4_ADDR(&gw, 0,0,0,0);
|
||||
IP4_ADDR(&ipaddr, 0,0,0,0);
|
||||
|
@ -85,17 +95,15 @@ int STDCALL network_task(void* arg)
|
|||
|
||||
/* Bring up the network interface */
|
||||
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input)) {
|
||||
#endif
|
||||
kputs("Unable to add network interface\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
netif_set_default(&netif);
|
||||
netif_set_up(&netif);
|
||||
|
||||
if (netif_is_up(&netif)) {
|
||||
kputs("Network interface is not up\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
kprintf("Starting DHCPCD...\n");
|
||||
dhcp_start(&netif);
|
||||
|
||||
|
@ -104,17 +112,24 @@ int STDCALL network_task(void* arg)
|
|||
rtl8139if_wait(&netif, 1);
|
||||
udelay(500000);
|
||||
}
|
||||
#endif
|
||||
|
||||
// start echo and ping server
|
||||
echo_init();
|
||||
ping_init();
|
||||
//ping_init();
|
||||
|
||||
while(!done) {
|
||||
#ifdef CONFIG_PCI
|
||||
rtl8139if_wait(&netif, 0);
|
||||
#elif defined(CONFIG_ROCKCREEK)
|
||||
rckemacif_wait(&netif, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CONFIG_ROCKCREEK
|
||||
dhcp_release(&netif);
|
||||
dhcp_stop(&netif);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -127,28 +142,16 @@ int network_shutdown(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tcp_init_ok(void* e)
|
||||
{
|
||||
kprintf("TCP/IP init COMPLETE!!!!!!");
|
||||
}
|
||||
|
||||
int network_init(void)
|
||||
{
|
||||
tcpip_init(tcp_init_ok,NULL);
|
||||
kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||
mmnif_open();
|
||||
kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||
return 0;
|
||||
#if 0
|
||||
#if defined(CONFIG_LWIP)
|
||||
// Initialize lwIP modules
|
||||
lwip_init();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_LWIP) && defined(CONFIG_PCI)
|
||||
#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK))
|
||||
return create_kernel_task(&netid, network_task, NULL);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ int main(void)
|
|||
kprintf("Current allocated memory: %u KBytes\n", atomic_int32_read(&total_allocated_pages)*(PAGE_SIZE/1024));
|
||||
kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE));
|
||||
|
||||
// sleep(5);
|
||||
// list_root();
|
||||
sleep(5);
|
||||
list_root();
|
||||
test_init();
|
||||
|
||||
per_core(current_task)->status = TASK_IDLE;
|
||||
|
|
|
@ -38,9 +38,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
//#define PING_USE_SOCKETS 1
|
||||
|
||||
|
||||
#include <metalsvm/stddef.h>
|
||||
#include <metalsvm/time.h>
|
||||
#include <metalsvm/processor.h>
|
||||
|
@ -56,6 +53,10 @@
|
|||
#include <lwip/timers.h>
|
||||
#include <lwip/inet_chksum.h>
|
||||
|
||||
#if LWIP_SOCKET
|
||||
#define PING_USE_SOCKETS 1
|
||||
#endif
|
||||
|
||||
#if PING_USE_SOCKETS
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/inet.h>
|
||||
|
@ -71,7 +72,7 @@
|
|||
|
||||
/** ping target - should be a "ip_addr_t" */
|
||||
#ifndef PING_TARGET
|
||||
#define PING_TARGET (netif_default?netif_default->gw:ip_addr_any)
|
||||
#define PING_TARGET (netif_default?netif_default->gw:ip_addr_any)
|
||||
#endif
|
||||
|
||||
/** ping receive timeout - in milliseconds */
|
||||
|
|
163
kernel/tests.c
163
kernel/tests.c
|
@ -26,14 +26,6 @@
|
|||
#include <metalsvm/syscall.h>
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
#include <asm/icc.h>
|
||||
#include <asm/RCCE_lib.h>
|
||||
#include <asm/RCCE.h>
|
||||
#include <asm/RCCE_lib.h>
|
||||
#include <asm/iRCCE.h>
|
||||
#include <asm/iRCCE_lib.h>
|
||||
|
||||
#include <asm/SCC_API.h>
|
||||
#include <lwip/sockets.h>
|
||||
#endif
|
||||
|
||||
static sem_t consuming, producing;
|
||||
|
@ -127,166 +119,23 @@ static int STDCALL join_test(void* arg)
|
|||
|
||||
void ping_send_now();
|
||||
|
||||
__inline int get_core_no(void)
|
||||
{
|
||||
unsigned int tmp;
|
||||
unsigned int pid;
|
||||
unsigned int x,y,z;
|
||||
/* Determine the local IP address from the core number in the
|
||||
* tile ID register
|
||||
*/
|
||||
tmp = ReadConfigReg(0xF8000000 + 0x100);
|
||||
x = (tmp>>3) & 0x0f; /* bits 06:03 */
|
||||
y = (tmp>>7) & 0x0f; /* bits 10:07 */
|
||||
z = (tmp ) & 0x07; /* bits 02:00 */
|
||||
pid = 12*y + 2*x + z;
|
||||
/* Add 1 to the processor ID to avoid *.*.*.0 IP addresses */
|
||||
return pid;
|
||||
}
|
||||
|
||||
void* server_task(void* e)
|
||||
{
|
||||
int sockfd, newsockfd, portno, clilen;
|
||||
char buffer[256];
|
||||
struct sockaddr_in serv_addr, cli_addr;
|
||||
int n;
|
||||
|
||||
/* First call to socket() function */
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
kprintf("ERROR opening socket");
|
||||
return;
|
||||
}
|
||||
/* Initialize socket structure */
|
||||
memset((char *) &serv_addr,0, sizeof(serv_addr));
|
||||
portno = 5001;
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
serv_addr.sin_port = htons(portno);
|
||||
|
||||
kprintf("binding");
|
||||
/* Now bind the host address using bind() call.*/
|
||||
if (bind(sockfd, (struct sockaddr *) &serv_addr,
|
||||
sizeof(serv_addr)) < 0)
|
||||
{
|
||||
kprintf("ERROR on binding");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now start listening for the clients, here process will
|
||||
* go in sleep mode and will wait for the incoming connection
|
||||
*/
|
||||
kprintf("listening");
|
||||
listen(sockfd,5);
|
||||
clilen = sizeof(cli_addr);
|
||||
|
||||
/* Accept actual connection from the client */
|
||||
kprintf("accepting");
|
||||
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,
|
||||
&clilen);
|
||||
if (newsockfd < 0)
|
||||
{
|
||||
kprintf("ERROR on accept");
|
||||
return;
|
||||
}
|
||||
/* If connection is established then start communicating */
|
||||
memset(buffer,0,256);
|
||||
kprintf("recieving");
|
||||
n = read( newsockfd,buffer,255 );
|
||||
if (n < 0)
|
||||
{
|
||||
kprintf("ERROR reading from socket");
|
||||
return;
|
||||
}
|
||||
kprintf("Here is the message: %s\n",buffer);
|
||||
|
||||
/* Write a response to the client */
|
||||
kprintf("writing");
|
||||
n = write(newsockfd,"I got your message",18);
|
||||
if (n < 0)
|
||||
{
|
||||
kprintf("ERROR writing to socket");
|
||||
return;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* client_task(void* e)
|
||||
{
|
||||
char dir[256];
|
||||
int sd;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in pin;
|
||||
struct hostent *hp;
|
||||
|
||||
|
||||
/* fill in the socket structure with host information */
|
||||
memset(&pin, 0, sizeof(pin));
|
||||
pin.sin_family = AF_INET;
|
||||
pin.sin_addr.s_addr = inet_addr("192.168.0.1");
|
||||
pin.sin_port = htons(5001);
|
||||
|
||||
/* grab an Internet domain socket */
|
||||
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
kprintf("socketfail");
|
||||
return;
|
||||
}
|
||||
|
||||
kprintf("connecting");
|
||||
/* connect to PORT on HOST */
|
||||
if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) {
|
||||
kprintf("connectfail");
|
||||
return;
|
||||
}
|
||||
kprintf("sending");
|
||||
/* send a message to the server PORT on machine HOST */
|
||||
if (send(sd, "HELLO THERE", strlen("HELLO THERE"), 0) == -1) {
|
||||
kprintf("sendfail");
|
||||
return;
|
||||
}
|
||||
kprintf("recieving");
|
||||
/* wait for a message to come back from the server */
|
||||
if (recv(sd, dir, 256, 0) == -1) {
|
||||
kprintf("recvfail");
|
||||
return;
|
||||
}
|
||||
|
||||
/* spew-out the results and bail out of here! */
|
||||
kprintf("%s\n", dir);
|
||||
|
||||
close(sd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int test_init(void)
|
||||
{
|
||||
if (!get_core_no())
|
||||
create_kernel_task(NULL,server_task,NULL);
|
||||
else
|
||||
create_kernel_task(NULL,client_task,NULL);
|
||||
char* argv[] = {"/bin/tests", NULL};
|
||||
|
||||
// char* argv[] = {"/bin/tests", NULL};
|
||||
sem_init(&producing, 1);
|
||||
sem_init(&consuming, 0);
|
||||
mailbox_int32_init(&mbox);
|
||||
|
||||
// sem_init(&producing, 1);
|
||||
// sem_init(&consuming, 0);
|
||||
// mailbox_int32_init(&mbox);
|
||||
|
||||
// create_kernel_task(NULL, foo, "Hello from foo1\n");
|
||||
create_kernel_task(NULL, foo, "Hello from foo1\n");
|
||||
//create_kernel_task(NULL, join_test, NULL);
|
||||
//create_kernel_task(NULL, producer, NULL);
|
||||
//create_kernel_task(NULL, consumer, NULL);
|
||||
//create_kernel_task(NULL, ping, NULL);
|
||||
//create_user_task(NULL, "/bin/hello", argv);
|
||||
// create_user_task(NULL, "/bin/tests", argv);
|
||||
create_user_task(NULL, "/bin/tests", argv);
|
||||
//create_user_task(NULL, "/bin/jacobi", argv);
|
||||
//create_user_task(NULL, "/bin/jacobi", argv);
|
||||
|
||||
#ifdef CONFIG_LWIP
|
||||
// use ping to test LWIP
|
||||
// ping_send_now();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,25 @@
|
|||
FUTURE
|
||||
|
||||
* TODO: The lwIP source code makes some invalid assumptions on processor
|
||||
word-length, storage sizes and alignment. See the mailing lists for
|
||||
problems with exoteric (/DSP) architectures showing these problems.
|
||||
We still have to fix some of these issues neatly.
|
||||
|
||||
HISTORY
|
||||
|
||||
(CVS HEAD)
|
||||
|
||||
* [Enter new changes just after this line - do not remove this line]
|
||||
|
||||
++ New features:
|
||||
|
||||
|
||||
++ Bugfixes:
|
||||
|
||||
|
||||
|
||||
|
||||
(STABLE-1.4.0)
|
||||
|
||||
++ New features:
|
||||
|
||||
2011-03-27: Simon Goldschmidt
|
||||
* tcp_impl.h, tcp_in.c, tcp_out.c: Removed 'dataptr' from 'struct tcp_seg' and
|
||||
calculate it in tcp_zero_window_probe (the only place where it was used).
|
||||
|
||||
2010-11-21: Simon Goldschmidt
|
||||
* dhcp.c/.h: Added a function to deallocate the struct dhcp from a netif
|
||||
(fixes bug #31525).
|
||||
|
@ -233,6 +240,62 @@ HISTORY
|
|||
|
||||
++ Bugfixes:
|
||||
|
||||
2011-04-20: Simon Goldschmidt
|
||||
* sys_arch.txt: sys_arch_timeouts() is not needed any more.
|
||||
|
||||
2011-04-13: Simon Goldschmidt
|
||||
* tcp.c, udp.c: Fixed bug #33048 (Bad range for IP source port numbers) by
|
||||
using ports in the IANA private/dynamic range (49152 through 65535).
|
||||
|
||||
2011-03-29: Simon Goldschmidt, patch by Emil Lhungdahl:
|
||||
* etharp.h/.c: Fixed broken VLAN support.
|
||||
|
||||
2011-03-27: Simon Goldschmidt
|
||||
* tcp.c: Fixed bug #32926 (TCP_RMV(&tcp_bound_pcbs) is called on unbound tcp
|
||||
pcbs) by checking if the pcb was bound (local_port != 0).
|
||||
|
||||
2011-03-27: Simon Goldschmidt
|
||||
* ppp.c: Fixed bug #32280 (ppp: a pbuf is freed twice)
|
||||
|
||||
2011-03-27: Simon Goldschmidt
|
||||
* sockets.c: Fixed bug #32906: lwip_connect+lwip_send did not work for udp and
|
||||
raw pcbs with LWIP_TCPIP_CORE_LOCKING==1.
|
||||
|
||||
2011-03-27: Simon Goldschmidt
|
||||
* tcp_out.c: Fixed bug #32820 (Outgoing TCP connections created before route
|
||||
is present never times out) by starting retransmission timer before checking
|
||||
route.
|
||||
|
||||
2011-03-22: Simon Goldschmidt
|
||||
* ppp.c: Fixed bug #32648 (PPP code crashes when terminating a link) by only
|
||||
calling sio_read_abort() if the file descriptor is valid.
|
||||
|
||||
2011-03-14: Simon Goldschmidt
|
||||
* err.h/.c, sockets.c, api_msg.c: fixed bug #31748 (Calling non-blocking connect
|
||||
more than once can render a socket useless) since it mainly involves changing
|
||||
"FATAL" classification of error codes: ERR_USE and ERR_ISCONN just aren't fatal.
|
||||
|
||||
2011-03-13: Simon Goldschmidt
|
||||
* sockets.c: fixed bug #32769 (ESHUTDOWN is linux-specific) by fixing
|
||||
err_to_errno_table (ERR_CLSD: ENOTCONN instead of ESHUTDOWN), ERR_ISCONN:
|
||||
use EALRADY instead of -1
|
||||
|
||||
2011-03-13: Simon Goldschmidt
|
||||
* api_lib.c: netconn_accept: return ERR_ABRT instead of ERR_CLSD if the
|
||||
connection has been aborted by err_tcp (since this is not a normal closing
|
||||
procedure).
|
||||
|
||||
2011-03-13: Simon Goldschmidt
|
||||
* tcp.c: tcp_bind: return ERR_VAL instead of ERR_ISCONN when trying to bind
|
||||
with pcb->state != CLOSED
|
||||
|
||||
2011-02-17: Simon Goldschmidt
|
||||
* rawapi.txt: Fixed bug #32561 tcp_poll argument definition out-of-order in
|
||||
documentation
|
||||
|
||||
2011-02-17: Simon Goldschmidt
|
||||
* many files: Added missing U/UL modifiers to fix 16-bit-arch portability.
|
||||
|
||||
2011-01-24: Simon Goldschmidt
|
||||
* sockets.c: Fixed bug #31741: lwip_select seems to have threading problems
|
||||
|
||||
|
|
|
@ -251,8 +251,9 @@ if a call to tcp_write() has failed because memory wasn't available,
|
|||
the application may use the polling functionality to call tcp_write()
|
||||
again when the connection has been idle for a while.
|
||||
|
||||
- void tcp_poll(struct tcp_pcb *pcb, u8_t interval,
|
||||
err_t (* poll)(void *arg, struct tcp_pcb *tpcb))
|
||||
- void tcp_poll(struct tcp_pcb *pcb,
|
||||
err_t (* poll)(void *arg, struct tcp_pcb *tpcb),
|
||||
u8_t interval)
|
||||
|
||||
Specifies the polling interval and the callback function that should
|
||||
be called to poll the application. The interval is specified in
|
||||
|
|
|
@ -123,18 +123,6 @@ The following functions must be implemented by the sys_arch:
|
|||
sys_arch_mbox_fetch(mbox,msg,1)
|
||||
although this would introduce unnecessary delays.
|
||||
|
||||
- struct sys_timeouts *sys_arch_timeouts(void)
|
||||
|
||||
Returns a pointer to the per-thread sys_timeouts structure. In lwIP,
|
||||
each thread has a list of timeouts which is repressented as a linked
|
||||
list of sys_timeout structures. The sys_timeouts structure holds a
|
||||
pointer to a linked list of timeouts. This function is called by
|
||||
the lwIP timeout scheduler and must not return a NULL value.
|
||||
|
||||
In a single thread sys_arch implementation, this function will
|
||||
simply return a pointer to a global sys_timeouts variable stored in
|
||||
the sys_arch module.
|
||||
|
||||
If threads are supported by the underlying operating system and if
|
||||
such functionality is needed in lwIP, the following function will have
|
||||
to be implemented as well:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
C_source := err.c sockets.c netbuf.c api_lib.c api_msg.c netdb.c netifapi.c tcpip.c
|
||||
C_source := api_lib.c api_msg.c err.c netbuf.c netifapi.c sockets.c tcpip.c
|
||||
MODULE := lwip_src_api
|
||||
|
||||
include $(TOPDIR)/Makefile.inc
|
||||
|
|
|
@ -307,9 +307,9 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
|
|||
API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
|
||||
|
||||
if (newconn == NULL) {
|
||||
/* connection has been closed */
|
||||
NETCONN_SET_SAFE_ERR(conn, ERR_CLSD);
|
||||
return ERR_CLSD;
|
||||
/* connection has been aborted */
|
||||
NETCONN_SET_SAFE_ERR(conn, ERR_ABRT);
|
||||
return ERR_ABRT;
|
||||
}
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
/* Let the stack know that we have accepted the connection. */
|
||||
|
|
|
@ -950,12 +950,7 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
|||
conn->current_msg = NULL;
|
||||
conn->state = NETCONN_NONE;
|
||||
if (!was_blocking) {
|
||||
SYS_ARCH_DECL_PROTECT(lev);
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
if (conn->last_err == ERR_INPROGRESS) {
|
||||
conn->last_err = ERR_OK;
|
||||
}
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
NETCONN_SET_SAFE_ERR(conn, ERR_OK);
|
||||
}
|
||||
API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0);
|
||||
|
||||
|
|
|
@ -49,14 +49,14 @@ static const char *err_strerr[] = {
|
|||
"Operation in progress.", /* ERR_INPROGRESS -5 */
|
||||
"Illegal value.", /* ERR_VAL -6 */
|
||||
"Operation would block.", /* ERR_WOULDBLOCK -7 */
|
||||
"Connection aborted.", /* ERR_ABRT -8 */
|
||||
"Connection reset.", /* ERR_RST -9 */
|
||||
"Connection closed.", /* ERR_CLSD -10 */
|
||||
"Not connected.", /* ERR_CONN -11 */
|
||||
"Illegal argument.", /* ERR_ARG -12 */
|
||||
"Address in use.", /* ERR_USE -13 */
|
||||
"Low-level netif error.", /* ERR_IF -14 */
|
||||
"Already connected.", /* ERR_ISCONN -15 */
|
||||
"Address in use.", /* ERR_USE -8 */
|
||||
"Already connected.", /* ERR_ISCONN -9 */
|
||||
"Connection aborted.", /* ERR_ABRT -10 */
|
||||
"Connection reset.", /* ERR_RST -11 */
|
||||
"Connection closed.", /* ERR_CLSD -12 */
|
||||
"Not connected.", /* ERR_CONN -13 */
|
||||
"Illegal argument.", /* ERR_ARG -14 */
|
||||
"Low-level netif error.", /* ERR_IF -15 */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,14 +141,14 @@ static const int err_to_errno_table[] = {
|
|||
EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */
|
||||
EINVAL, /* ERR_VAL -6 Illegal value. */
|
||||
EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */
|
||||
ECONNABORTED, /* ERR_ABRT -8 Connection aborted. */
|
||||
ECONNRESET, /* ERR_RST -9 Connection reset. */
|
||||
ESHUTDOWN, /* ERR_CLSD -10 Connection closed. */
|
||||
ENOTCONN, /* ERR_CONN -11 Not connected. */
|
||||
EIO, /* ERR_ARG -12 Illegal argument. */
|
||||
EADDRINUSE, /* ERR_USE -13 Address in use. */
|
||||
-1, /* ERR_IF -14 Low-level netif error */
|
||||
-1, /* ERR_ISCONN -15 Already connected. */
|
||||
EADDRINUSE, /* ERR_USE -8 Address in use. */
|
||||
EALREADY, /* ERR_ISCONN -9 Already connected. */
|
||||
ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */
|
||||
ECONNRESET, /* ERR_RST -11 Connection reset. */
|
||||
ENOTCONN, /* ERR_CLSD -12 Connection closed. */
|
||||
ENOTCONN, /* ERR_CONN -13 Not connected. */
|
||||
EIO, /* ERR_ARG -14 Illegal argument. */
|
||||
-1, /* ERR_IF -15 Low-level netif error */
|
||||
};
|
||||
|
||||
#define ERR_TO_ERRNO_TABLE_SIZE \
|
||||
|
@ -847,8 +847,12 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
|
|||
inet_addr_to_ipaddr_p(remote_addr, &to_in->sin_addr);
|
||||
remote_port = ntohs(to_in->sin_port);
|
||||
} else {
|
||||
remote_addr = IP_ADDR_ANY;
|
||||
remote_port = 0;
|
||||
remote_addr = &sock->conn->pcb.raw->remote_ip;
|
||||
if (sock->conn->type == NETCONN_RAW) {
|
||||
remote_port = 0;
|
||||
} else {
|
||||
remote_port = sock->conn->pcb.udp->remote_port;
|
||||
}
|
||||
}
|
||||
|
||||
LOCK_TCPIP_CORE();
|
||||
|
@ -890,7 +894,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
|
|||
netbuf_fromport(&buf) = 0;
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, short_size=%d"U16_F", flags=0x%x to=",
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, short_size=%"U16_F", flags=0x%x to=",
|
||||
s, data, short_size, flags));
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &buf.addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", remote_port));
|
||||
|
|
|
@ -137,7 +137,7 @@ tcpip_thread(void *arg)
|
|||
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||
|
||||
default:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: %d\n", (const char*)msg->type));
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: %d\n", msg->type));
|
||||
LWIP_ASSERT("tcpip_thread: invalid message", 0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
C_source := dhcp.c raw.c init.c mem.c memp.c netif.c pbuf.c stats.c udp.c tcp.c tcp_in.c tcp_out.c sys.c def.c timers.c
|
||||
C_source := dhcp.c raw.c init.c mem.c memp.c netif.c pbuf.c stats.c udp.c tcp.c tcp_in.c tcp_out.c def.c timers.c
|
||||
MODULE := lwip_src_core
|
||||
|
||||
include $(TOPDIR)/Makefile.inc
|
||||
|
|
|
@ -965,11 +965,11 @@ dhcp_bind(struct netif *netif)
|
|||
/* subnet mask not given, choose a safe subnet mask given the network class */
|
||||
u8_t first_octet = ip4_addr1(&dhcp->offered_ip_addr);
|
||||
if (first_octet <= 127) {
|
||||
ip4_addr_set_u32(&sn_mask, PP_HTONL(0xff000000));
|
||||
ip4_addr_set_u32(&sn_mask, PP_HTONL(0xff000000UL));
|
||||
} else if (first_octet >= 192) {
|
||||
ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffffff00));
|
||||
ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffffff00UL));
|
||||
} else {
|
||||
ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffff0000));
|
||||
ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffff0000UL));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -979,7 +979,7 @@ dhcp_bind(struct netif *netif)
|
|||
/* copy network address */
|
||||
ip_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask);
|
||||
/* use first host address on network as gateway */
|
||||
ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001));
|
||||
ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001UL));
|
||||
}
|
||||
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
|
|
|
@ -191,7 +191,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||
ip_addr_copy(iphdr->dest, *ip_current_src_addr());
|
||||
ICMPH_TYPE_SET(iecho, ICMP_ER);
|
||||
/* adjust the checksum */
|
||||
if (iecho->chksum >= PP_HTONS(0xffff - (ICMP_ECHO << 8))) {
|
||||
if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) {
|
||||
iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1;
|
||||
} else {
|
||||
iecho->chksum += PP_HTONS(ICMP_ECHO << 8);
|
||||
|
|
|
@ -100,7 +100,7 @@ Steve Reynolds
|
|||
*/
|
||||
#define IGMP_TTL 1
|
||||
#define IGMP_MINLEN 8
|
||||
#define ROUTER_ALERT 0x9404
|
||||
#define ROUTER_ALERT 0x9404U
|
||||
#define ROUTER_ALERTLEN 4
|
||||
|
||||
/*
|
||||
|
|
|
@ -201,7 +201,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
|||
}
|
||||
|
||||
/* Incrementally update the IP checksum. */
|
||||
if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffff - 0x100)) {
|
||||
if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffffU - 0x100)) {
|
||||
IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100) + 1);
|
||||
} else {
|
||||
IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100));
|
||||
|
|
|
@ -93,7 +93,7 @@ ip4_addr_netmask_valid(u32_t netmask)
|
|||
u32_t nm_hostorder = lwip_htonl(netmask);
|
||||
|
||||
/* first, check for the first zero */
|
||||
for (mask = 1U << 31 ; mask != 0; mask >>= 1) {
|
||||
for (mask = 1UL << 31 ; mask != 0; mask >>= 1) {
|
||||
if ((nm_hostorder & mask) == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "lwip/netif.h"
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/tcp_impl.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
|
|
|
@ -1,304 +1,66 @@
|
|||
/**
|
||||
* @file
|
||||
* lwIP Operating System abstraction
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/sys.h"
|
||||
|
||||
/* Most of the functions defined in sys.h must be implemented in the
|
||||
* architecture-dependent file sys_arch.c */
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <system/threads/bthread.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <metalsvm/time.h>
|
||||
#include <asm/tasks.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#endif
|
||||
/* sys_now(): retrives tick count to mesure system time
|
||||
*
|
||||
*/
|
||||
u32_t sys_now(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetTickCount();
|
||||
#else
|
||||
return get_clock_tick();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !NO_SYS
|
||||
|
||||
/**
|
||||
* Sleep for some ms. Timeouts are NOT processed while sleeping.
|
||||
*
|
||||
* @param ms number of milliseconds to sleep
|
||||
*/
|
||||
void
|
||||
sys_msleep(u32_t ms)
|
||||
{
|
||||
if (ms > 0) {
|
||||
sys_sem_t delaysem;
|
||||
err_t err = sys_sem_new(&delaysem, 0);
|
||||
if (err == ERR_OK) {
|
||||
sys_arch_sem_wait(&delaysem, ms);
|
||||
sys_sem_free(&delaysem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* sys_thread_new(): Spawns a new thread with given attributes as supportet
|
||||
* Note: In MetalSVM this is realized as kernel tasks
|
||||
*/
|
||||
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
|
||||
{
|
||||
#ifdef WIN32
|
||||
bthread_t tmp;
|
||||
bthread_attr_t tattr;
|
||||
tattr.creation_flags = NULL;
|
||||
tattr.thread_id = NULL;
|
||||
tattr.stacksize = stacksize;
|
||||
bthread_create(&tmp,NULL,thread,arg);
|
||||
return tmp;
|
||||
#else
|
||||
tid_t tmp;
|
||||
create_kernel_task(&tmp,thread,arg);
|
||||
return tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* sys_sem_free(): destroy's given semaphore
|
||||
* and releases system resources.
|
||||
* This semaphore also gets invalid.
|
||||
*/
|
||||
void sys_sem_free(sys_sem_t* sem)
|
||||
{
|
||||
sem->valid = FALSE;
|
||||
sem_destroy(&sem->sem);
|
||||
}
|
||||
/* sys_sem_valid(): returns if semaphore is valid
|
||||
* at the moment
|
||||
*/
|
||||
int sys_sem_valid(sys_sem_t* sem)
|
||||
{
|
||||
return sem->valid;
|
||||
}
|
||||
|
||||
/* sys_sem_new(): creates a new semaphre with given count.
|
||||
* This semaphore becomes valid
|
||||
*/
|
||||
err_t sys_sem_new(sys_sem_t* sem,u8_t count)
|
||||
{
|
||||
sem->valid = TRUE;
|
||||
return sem_init(&sem->sem,count);
|
||||
}
|
||||
/* sys_sem_set_invalid(): this semapohore becomes invalid
|
||||
* Note: this does not mean it is destroyed
|
||||
*/
|
||||
void sys_sem_set_invalid(sys_sem_t * sem)
|
||||
{
|
||||
sem->valid = FALSE;
|
||||
}
|
||||
|
||||
/* sys_sem_signal(): this semaphore is signaled
|
||||
*
|
||||
*/
|
||||
void sys_sem_signal(sys_sem_t* sem)
|
||||
{
|
||||
sem_post(&sem->sem);
|
||||
}
|
||||
/* sys_arch_sem_wait): wait for the given semaphore for
|
||||
* a given timeout
|
||||
* Note: timeout = 0 means wait forever
|
||||
*/
|
||||
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
|
||||
{
|
||||
int err;
|
||||
if (!timeout)
|
||||
return sem_wait(&sem->sem);
|
||||
while (timeout)
|
||||
{
|
||||
err = sem_trywait(&sem->sem);
|
||||
#ifdef WIN32
|
||||
if (err != 0x00000102L)
|
||||
return err;
|
||||
#else
|
||||
if (err != -1)
|
||||
return err;
|
||||
#endif
|
||||
timeout--;
|
||||
}
|
||||
return SYS_ARCH_TIMEOUT;
|
||||
}
|
||||
|
||||
/* sys_mbox_valid() : returns if the given mailbox
|
||||
* is valid
|
||||
*/
|
||||
int sys_mbox_valid(sys_mbox_t * mbox)
|
||||
{
|
||||
return mbox->valid;
|
||||
}
|
||||
/* sys_arch_mbox_fetch(): wait for the given mailbox for a specified
|
||||
* amount of time.
|
||||
* Note: timeout = 0 means wait forever
|
||||
*/
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void **msg, u32_t timeout)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (!timeout)
|
||||
return mailbox_ptr_fetch(&mbox->mailbox,msg);
|
||||
|
||||
while(timeout)
|
||||
{
|
||||
if (!mailbox_ptr_tryfetch(&mbox->mailbox,msg))
|
||||
return 0;
|
||||
timeout--;
|
||||
}
|
||||
return SYS_ARCH_TIMEOUT;
|
||||
|
||||
}
|
||||
/* sys_mbox_free() : free the given mailbox, release the system resources
|
||||
* and set mbox to invalid
|
||||
*/
|
||||
void sys_mbox_free(sys_mbox_t* mbox)
|
||||
{
|
||||
mbox->valid = FALSE;
|
||||
mailbox_ptr_destroy(&mbox->mailbox);
|
||||
}
|
||||
|
||||
/* sys_arch_mbox_tryfetch(): poll for new data in mailbox
|
||||
*
|
||||
*/
|
||||
u32_t sys_arch_mbox_tryfetch(sys_mbox_t* mbox, void** msg)
|
||||
{
|
||||
return mailbox_ptr_tryfetch(&mbox->mailbox,msg);
|
||||
}
|
||||
|
||||
/* sys_mbox_new(): create a new mailbox with a minimum size of "size"
|
||||
*
|
||||
*/
|
||||
err_t sys_mbox_new(sys_mbox_t* mbox,int size)
|
||||
{
|
||||
mbox->valid = TRUE;
|
||||
return mailbox_ptr_init(&mbox->mailbox);
|
||||
}
|
||||
/* sys_mbox_set_invalid(): set the given mailbox to invalid
|
||||
* Note: system resources are NOT freed
|
||||
*/
|
||||
void sys_mbox_set_invalid(sys_mbox_t* mbox)
|
||||
{
|
||||
mbox->valid =FALSE;
|
||||
}
|
||||
/* sys_mbox_trypost(): try to post data to the mailbox
|
||||
* Note: There is at the moment no try post implemented
|
||||
* so we use the normal post instead
|
||||
*/
|
||||
int sys_mbox_trypost(sys_mbox_t* mbox,void* msg)
|
||||
{
|
||||
return mailbox_ptr_post(&mbox->mailbox,msg);
|
||||
}
|
||||
|
||||
/* sys_mbox_post(): post new data to the mailbox
|
||||
*
|
||||
*/
|
||||
void sys_mbox_post(sys_mbox_t* mbox,void* msg)
|
||||
{
|
||||
mailbox_ptr_post(&mbox->mailbox,msg);
|
||||
}
|
||||
|
||||
/* sys_mutex_lock(): lock the given mutex
|
||||
* Note: There is no specific mutex in MetalSVM
|
||||
* so we use a semaphore with 1 element
|
||||
*/
|
||||
void sys_mutex_lock(sys_mutex_t* mutex)
|
||||
{
|
||||
#ifdef WIN32
|
||||
bthread_mutex_lock(mutex);
|
||||
#else
|
||||
sem_wait(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* sys_mutex_unlock(): unlock the given mutex
|
||||
*
|
||||
*/
|
||||
void sys_mutex_unlock(sys_mutex_t* mutex)
|
||||
{
|
||||
#ifdef WIN32
|
||||
bthread_mutex_unlock(mutex);
|
||||
#else
|
||||
sem_post(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* sys_mutex_new(): create a new mutex
|
||||
*
|
||||
*/
|
||||
err_t sys_mutex_new(sys_mutex_t * mutex)
|
||||
{
|
||||
#ifdef WIN32
|
||||
bthread_mutex_init(mutex);
|
||||
return 0;
|
||||
#else
|
||||
sem_init(mutex,1);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* sys_init(): init needed system resources
|
||||
* Note: At the moment there are none
|
||||
*/
|
||||
void sys_init()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* lwIP Operating System abstraction
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/sys.h"
|
||||
|
||||
/* Most of the functions defined in sys.h must be implemented in the
|
||||
* architecture-dependent file sys_arch.c */
|
||||
|
||||
#if !NO_SYS
|
||||
|
||||
/**
|
||||
* Sleep for some ms. Timeouts are NOT processed while sleeping.
|
||||
*
|
||||
* @param ms number of milliseconds to sleep
|
||||
*/
|
||||
void
|
||||
sys_msleep(u32_t ms)
|
||||
{
|
||||
if (ms > 0) {
|
||||
sys_sem_t delaysem;
|
||||
err_t err = sys_sem_new(&delaysem, 0);
|
||||
if (err == ERR_OK) {
|
||||
sys_arch_sem_wait(&delaysem, ms);
|
||||
sys_sem_free(&delaysem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !NO_SYS */
|
||||
|
|
|
@ -91,7 +91,7 @@ struct tcp_pcb *tcp_tw_pcbs;
|
|||
#define NUM_TCP_PCB_LISTS 4
|
||||
#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3
|
||||
/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */
|
||||
struct tcp_pcb **tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
|
||||
struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
|
||||
&tcp_active_pcbs, &tcp_tw_pcbs};
|
||||
|
||||
/** Only used for temporary storage. */
|
||||
|
@ -173,7 +173,9 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
|
|||
* is erroneous, but this should never happen as the pcb has in those cases
|
||||
* been freed, and so any remaining handles are bogus. */
|
||||
err = ERR_OK;
|
||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||
if (pcb->local_port != 0) {
|
||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||
}
|
||||
memp_free(MEMP_TCP_PCB, pcb);
|
||||
pcb = NULL;
|
||||
break;
|
||||
|
@ -391,6 +393,7 @@ tcp_abort(struct tcp_pcb *pcb)
|
|||
* to any local address
|
||||
* @param port the local port to bind to
|
||||
* @return ERR_USE if the port is already in use
|
||||
* ERR_VAL if bind failed because the PCB is not in a valid state
|
||||
* ERR_OK if bound
|
||||
*/
|
||||
err_t
|
||||
|
@ -400,7 +403,7 @@ tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
|
|||
int max_pcb_list = NUM_TCP_PCB_LISTS;
|
||||
struct tcp_pcb *cpcb;
|
||||
|
||||
LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
||||
LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL);
|
||||
|
||||
#if SO_REUSE
|
||||
/* Unless the REUSEADDR flag is set,
|
||||
|
@ -440,7 +443,7 @@ tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
|
|||
}
|
||||
|
||||
if (!ip_addr_isany(ipaddr)) {
|
||||
pcb->local_ip = *(ipaddr);
|
||||
pcb->local_ip = *ipaddr;
|
||||
}
|
||||
pcb->local_port = port;
|
||||
TCP_REG(&tcp_bound_pcbs, pcb);
|
||||
|
@ -516,7 +519,9 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
|||
lpcb->ttl = pcb->ttl;
|
||||
lpcb->tos = pcb->tos;
|
||||
ip_addr_copy(lpcb->local_ip, pcb->local_ip);
|
||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||
if (pcb->local_port != 0) {
|
||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||
}
|
||||
memp_free(MEMP_TCP_PCB, pcb);
|
||||
#if LWIP_CALLBACK_API
|
||||
lpcb->accept = tcp_accept_null;
|
||||
|
@ -606,17 +611,19 @@ tcp_new_port(void)
|
|||
int i;
|
||||
struct tcp_pcb *pcb;
|
||||
#ifndef TCP_LOCAL_PORT_RANGE_START
|
||||
#define TCP_LOCAL_PORT_RANGE_START 4096
|
||||
#define TCP_LOCAL_PORT_RANGE_END 0x7fff
|
||||
/* From http://www.iana.org/assignments/port-numbers:
|
||||
"The Dynamic and/or Private Ports are those from 49152 through 65535" */
|
||||
#define TCP_LOCAL_PORT_RANGE_START 0xc000
|
||||
#define TCP_LOCAL_PORT_RANGE_END 0xffff
|
||||
#endif
|
||||
static u16_t port = TCP_LOCAL_PORT_RANGE_START;
|
||||
|
||||
again:
|
||||
if (++port > TCP_LOCAL_PORT_RANGE_END) {
|
||||
if (port++ >= TCP_LOCAL_PORT_RANGE_END) {
|
||||
port = TCP_LOCAL_PORT_RANGE_START;
|
||||
}
|
||||
/* Check all PCB lists. */
|
||||
for (i = 0; i < NUM_TCP_PCB_LISTS; i++) {
|
||||
for (i = 0; i < NUM_TCP_PCB_LISTS; i++) {
|
||||
for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) {
|
||||
if (pcb->local_port == port) {
|
||||
goto again;
|
||||
|
@ -644,8 +651,9 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
|
|||
{
|
||||
err_t ret;
|
||||
u32_t iss;
|
||||
u16_t old_local_port;
|
||||
|
||||
LWIP_ERROR("tcp_connect: can only connected from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
||||
LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port));
|
||||
if (ipaddr != NULL) {
|
||||
|
@ -668,6 +676,7 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
|
|||
ip_addr_copy(pcb->local_ip, netif->ip_addr);
|
||||
}
|
||||
|
||||
old_local_port = pcb->local_port;
|
||||
if (pcb->local_port == 0) {
|
||||
pcb->local_port = tcp_new_port();
|
||||
}
|
||||
|
@ -719,7 +728,9 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
|
|||
if (ret == ERR_OK) {
|
||||
/* SYN segment was enqueued, changed the pcbs state now */
|
||||
pcb->state = SYN_SENT;
|
||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||
if (old_local_port != 0) {
|
||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||
}
|
||||
TCP_REG(&tcp_active_pcbs, pcb);
|
||||
snmp_inc_tcpactiveopens();
|
||||
|
||||
|
|
|
@ -291,7 +291,6 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||
/* Set up a tcp_seg structure. */
|
||||
inseg.next = NULL;
|
||||
inseg.len = p->tot_len;
|
||||
inseg.dataptr = p->payload;
|
||||
inseg.p = p;
|
||||
inseg.tcphdr = tcphdr;
|
||||
|
||||
|
@ -1167,9 +1166,6 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||
LWIP_ASSERT("pbuf_header failed", 0);
|
||||
}
|
||||
}
|
||||
/* KJM following line changed to use p->payload rather than inseg->p->payload
|
||||
to fix bug #9076 */
|
||||
inseg.dataptr = p->payload;
|
||||
inseg.len -= (u16_t)(pcb->rcv_nxt - seqno);
|
||||
inseg.tcphdr->seqno = seqno = pcb->rcv_nxt;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -166,7 +166,6 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno,
|
|||
seg->flags = optflags;
|
||||
seg->next = NULL;
|
||||
seg->p = p;
|
||||
seg->dataptr = p->payload;
|
||||
seg->len = p->tot_len - optlen;
|
||||
#if TCP_OVERSIZE_DBGCHECK
|
||||
seg->oversize_left = 0;
|
||||
|
@ -590,10 +589,6 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
|||
seg->chksum_swapped = chksum_swapped;
|
||||
seg->flags |= TF_SEG_DATA_CHECKSUMMED;
|
||||
#endif /* TCP_CHECKSUM_ON_COPY */
|
||||
/* Fix dataptr for the nocopy case */
|
||||
if ((apiflags & TCP_WRITE_FLAG_COPY) == 0) {
|
||||
seg->dataptr = (u8_t*)arg + pos;
|
||||
}
|
||||
|
||||
/* first segment of to-be-queued data? */
|
||||
if (queue == NULL) {
|
||||
|
@ -1083,6 +1078,12 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Set retransmission timer running if it is not currently enabled
|
||||
This must be set before checking the route. */
|
||||
if (pcb->rtime == -1) {
|
||||
pcb->rtime = 0;
|
||||
}
|
||||
|
||||
/* If we don't have a local IP address, we get one by
|
||||
calling ip_route(). */
|
||||
if (ip_addr_isany(&(pcb->local_ip))) {
|
||||
|
@ -1093,11 +1094,6 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
|||
ip_addr_copy(pcb->local_ip, netif->ip_addr);
|
||||
}
|
||||
|
||||
/* Set retransmission timer running if it is not currently enabled */
|
||||
if(pcb->rtime == -1) {
|
||||
pcb->rtime = 0;
|
||||
}
|
||||
|
||||
if (pcb->rttest == 0) {
|
||||
pcb->rttest = tcp_ticks;
|
||||
pcb->rtseq = ntohl(seg->tcphdr->seqno);
|
||||
|
@ -1444,7 +1440,9 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
|
|||
TCPH_FLAGS_SET(tcphdr, TCP_ACK | TCP_FIN);
|
||||
} else {
|
||||
/* Data segment, copy in one byte from the head of the unacked queue */
|
||||
*((char *)p->payload + TCP_HLEN) = *(char *)seg->dataptr;
|
||||
struct tcp_hdr *thdr = (struct tcp_hdr *)seg->p->payload;
|
||||
char *d = ((char *)p->payload + TCP_HLEN);
|
||||
pbuf_copy_partial(seg->p, d, 1, TCPH_HDRLEN(thdr) * 4);
|
||||
}
|
||||
|
||||
#if CHECKSUM_GEN_TCP
|
||||
|
|
|
@ -292,8 +292,6 @@ sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)
|
|||
next_timeout = timeout;
|
||||
} else {
|
||||
for(t = next_timeout; t != NULL; t = t->next) {
|
||||
if (t->time ==0)
|
||||
t->time = 1;
|
||||
timeout->time -= t->time;
|
||||
if (t->next == NULL || t->next->time > timeout->time) {
|
||||
if (t->next != NULL) {
|
||||
|
|
|
@ -746,8 +746,10 @@ udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
|
|||
/* no port specified? */
|
||||
if (port == 0) {
|
||||
#ifndef UDP_LOCAL_PORT_RANGE_START
|
||||
#define UDP_LOCAL_PORT_RANGE_START 4096
|
||||
#define UDP_LOCAL_PORT_RANGE_END 0x7fff
|
||||
/* From http://www.iana.org/assignments/port-numbers:
|
||||
"The Dynamic and/or Private Ports are those from 49152 through 65535" */
|
||||
#define UDP_LOCAL_PORT_RANGE_START 0xc000
|
||||
#define UDP_LOCAL_PORT_RANGE_END 0xffff
|
||||
#endif
|
||||
port = UDP_LOCAL_PORT_RANGE_START;
|
||||
ipcb = udp_pcbs;
|
||||
|
|
|
@ -1,86 +1,85 @@
|
|||
|
||||
|
||||
#ifndef __ARCH_CC_H__
|
||||
#define __ARCH_CC_H__
|
||||
|
||||
#include "sys_arch.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <metalsvm/stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <asm/stddef.h>
|
||||
#endif
|
||||
|
||||
//#include <stdlib.h>
|
||||
//#include <string.h>
|
||||
//#include <time.h>
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
typedef char int8_t;
|
||||
typedef short int16_t;
|
||||
typedef int int32_t;
|
||||
/*
|
||||
typedef struct ___ip_addr_t {
|
||||
union {
|
||||
struct { uint8_t s_b1,s_b2,s_b3,s_b4; } S_un_b;
|
||||
struct { uint16_t s_w1,s_w2; } S_un_w;
|
||||
uint32_t addr;
|
||||
};
|
||||
}ip_addr_t;
|
||||
*/
|
||||
/*
|
||||
typedef struct ___ip_addr_t
|
||||
{
|
||||
uint32_t addr;
|
||||
}ip_addr_t;
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
typedef uint8_t u8_t;
|
||||
typedef int8_t s8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef int16_t s16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
typedef unsigned mem_ptr_t;
|
||||
|
||||
#define LWIP_ERR_T int
|
||||
|
||||
/* Define (sn)printf formatters for these lwIP types */
|
||||
#define U16_F "hu"
|
||||
#define S16_F "hd"
|
||||
#define X16_F "hx"
|
||||
#define U32_F "u"
|
||||
#define S32_F "d"
|
||||
#define X32_F "x"
|
||||
|
||||
/* Compiler hints for packing structures */
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT /*__attribute__((packed))*/
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
/* Plaform specific diagnostic output */
|
||||
#define LWIP_PLATFORM_DIAG(x) do { \
|
||||
kprintf(x); \
|
||||
} while (0)
|
||||
|
||||
#define LWIP_PLATFORM_ASSERT(x) do { \
|
||||
kprintf("Assert \"%s\" failed at line %d in %s\n", \
|
||||
x, __LINE__, __FILE__); \
|
||||
return NULL; \
|
||||
} while (0)
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_CC_H__
|
||||
#define __ARCH_CC_H__
|
||||
|
||||
/* Include some files for defining library routines */
|
||||
#include <metalsvm/string.h>
|
||||
//#include <sys/time.h>
|
||||
|
||||
/* Define platform endianness */
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif /* BYTE_ORDER */
|
||||
|
||||
/* Define generic types used in lwIP */
|
||||
typedef uint8_t u8_t;
|
||||
typedef int8_t s8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef int16_t s16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
typedef size_t mem_ptr_t;
|
||||
|
||||
/* Define (sn)printf formatters for these lwIP types */
|
||||
#define X8_F "02x"
|
||||
#define U16_F "hu"
|
||||
#define S16_F "hd"
|
||||
#define X16_F "hx"
|
||||
#define U32_F "lu"
|
||||
#define S32_F "ld"
|
||||
#define X32_F "lx"
|
||||
|
||||
/* Compiler hints for packing structures */
|
||||
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
#define MEM_ALIGNMENT 4
|
||||
#define ETH_PAD_SIZE 2
|
||||
|
||||
#define LWIP_CHKSUM_ALGORITHM 2
|
||||
|
||||
/* prototypes for printf() and abort() */
|
||||
#include <metalsvm/stdio.h>
|
||||
#include <metalsvm/stdlib.h>
|
||||
|
||||
/* Plaform specific diagnostic output */
|
||||
#define LWIP_PLATFORM_DIAG(x) do {kprintf x;} while(0)
|
||||
|
||||
#define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", \
|
||||
x, __LINE__, __FILE__); abort();} while(0)
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_PERF_H__
|
||||
#define __ARCH_PERF_H__
|
||||
|
||||
//#include <sys/times.h>
|
||||
|
||||
#ifdef PERF
|
||||
#define PERF_START { \
|
||||
unsigned long __c1l, __c1h, __c2l, __c2h; \
|
||||
__asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h))
|
||||
#define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \
|
||||
perf_print(__c1l, __c1h, __c2l, __c2h, x);}
|
||||
|
||||
/*#define PERF_START do { \
|
||||
struct tms __perf_start, __perf_end; \
|
||||
times(&__perf_start)
|
||||
#define PERF_STOP(x) times(&__perf_end); \
|
||||
perf_print_times(&__perf_start, &__perf_end, x);\
|
||||
} while(0)*/
|
||||
#else /* PERF */
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
#endif /* PERF */
|
||||
|
||||
void perf_print(unsigned long c1l, unsigned long c1h,
|
||||
unsigned long c2l, unsigned long c2h,
|
||||
char *key);
|
||||
|
||||
//void perf_print_times(struct tms *start, struct tms *end, char *key);
|
||||
|
||||
//void perf_init(char *fname);
|
||||
|
||||
#endif /* __ARCH_PERF_H__ */
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_PERF_H__
|
||||
#define __ARCH_PERF_H__
|
||||
|
||||
//#include <sys/times.h>
|
||||
|
||||
#ifdef PERF
|
||||
#define PERF_START { \
|
||||
unsigned long __c1l, __c1h, __c2l, __c2h; \
|
||||
__asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h))
|
||||
#define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \
|
||||
perf_print(__c1l, __c1h, __c2l, __c2h, x);}
|
||||
|
||||
/*#define PERF_START do { \
|
||||
struct tms __perf_start, __perf_end; \
|
||||
times(&__perf_start)
|
||||
#define PERF_STOP(x) times(&__perf_end); \
|
||||
perf_print_times(&__perf_start, &__perf_end, x);\
|
||||
} while(0)*/
|
||||
#else /* PERF */
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
#endif /* PERF */
|
||||
|
||||
void perf_print(unsigned long c1l, unsigned long c1h,
|
||||
unsigned long c2l, unsigned long c2h,
|
||||
char *key);
|
||||
|
||||
//void perf_print_times(struct tms *start, struct tms *end, char *key);
|
||||
|
||||
//void perf_init(char *fname);
|
||||
|
||||
#endif /* __ARCH_PERF_H__ */
|
||||
|
|
|
@ -1,52 +1,25 @@
|
|||
#ifndef __ARCH_SYS_ARCH_H__
|
||||
#define __ARCH_SYS_ARCH_H__
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <system/threads/bthread.h>
|
||||
#include "../../../../mailbox.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <asm/tasks.h>
|
||||
#include <metalsvm/mailbox.h>
|
||||
#include <metalsvm/errno.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
typedef bthread_mutex_t sys_mutex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bthread_sem_t sem;
|
||||
int valid;
|
||||
}sys_sem_t;
|
||||
|
||||
typedef struct
|
||||
{ mailbox_ptr_t mailbox;
|
||||
int valid;
|
||||
}sys_mbox_t;
|
||||
typedef bthread_t sys_thread_t;
|
||||
|
||||
#else
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
|
||||
typedef sem_t sys_mutex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sem_t sem;
|
||||
sem_t sem;
|
||||
int valid;
|
||||
}sys_sem_t;
|
||||
} sys_sem_t;
|
||||
|
||||
typedef struct
|
||||
{ mailbox_ptr_t mailbox;
|
||||
int valid;
|
||||
}sys_mbox_t;
|
||||
{ mailbox_ptr_t mailbox;
|
||||
int valid;
|
||||
} sys_mbox_t;
|
||||
|
||||
typedef tid_t* sys_thread_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ARCH_SYS_ARCH_H__ */
|
||||
#endif /* __ARCH_SYS_ARCH_H__ */
|
||||
|
|
|
@ -41,29 +41,29 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ICMP_ER 0 /* echo reply */
|
||||
#define ICMP_DUR 3 /* destination unreachable */
|
||||
#define ICMP_SQ 4 /* source quench */
|
||||
#define ICMP_RD 5 /* redirect */
|
||||
#define ICMP_ER 0 /* echo reply */
|
||||
#define ICMP_DUR 3 /* destination unreachable */
|
||||
#define ICMP_SQ 4 /* source quench */
|
||||
#define ICMP_RD 5 /* redirect */
|
||||
#define ICMP_ECHO 8 /* echo */
|
||||
#define ICMP_TE 11 /* time exceeded */
|
||||
#define ICMP_PP 12 /* parameter problem */
|
||||
#define ICMP_TS 13 /* timestamp */
|
||||
#define ICMP_TE 11 /* time exceeded */
|
||||
#define ICMP_PP 12 /* parameter problem */
|
||||
#define ICMP_TS 13 /* timestamp */
|
||||
#define ICMP_TSR 14 /* timestamp reply */
|
||||
#define ICMP_IRQ 15 /* information request */
|
||||
#define ICMP_IR 16 /* information reply */
|
||||
#define ICMP_IR 16 /* information reply */
|
||||
|
||||
enum icmp_dur_type {
|
||||
ICMP_DUR_NET = 0, /* net unreachable */
|
||||
ICMP_DUR_HOST = 1, /* host unreachable */
|
||||
ICMP_DUR_NET = 0, /* net unreachable */
|
||||
ICMP_DUR_HOST = 1, /* host unreachable */
|
||||
ICMP_DUR_PROTO = 2, /* protocol unreachable */
|
||||
ICMP_DUR_PORT = 3, /* port unreachable */
|
||||
ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
|
||||
ICMP_DUR_SR = 5 /* source route failed */
|
||||
ICMP_DUR_PORT = 3, /* port unreachable */
|
||||
ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
|
||||
ICMP_DUR_SR = 5 /* source route failed */
|
||||
};
|
||||
|
||||
enum icmp_te_type {
|
||||
ICMP_TE_TTL = 0, /* time to live exceeded in transit */
|
||||
ICMP_TE_TTL = 0, /* time to live exceeded in transit */
|
||||
ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
|
||||
};
|
||||
|
||||
|
|
|
@ -122,10 +122,10 @@ struct ip_hdr {
|
|||
PACK_STRUCT_FIELD(u16_t _id);
|
||||
/* fragment offset field */
|
||||
PACK_STRUCT_FIELD(u16_t _offset);
|
||||
#define IP_RF 0x8000 /* reserved fragment flag */
|
||||
#define IP_DF 0x4000 /* dont fragment flag */
|
||||
#define IP_MF 0x2000 /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
|
||||
#define IP_RF 0x8000U /* reserved fragment flag */
|
||||
#define IP_DF 0x4000U /* dont fragment flag */
|
||||
#define IP_MF 0x2000U /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */
|
||||
/* time to live */
|
||||
PACK_STRUCT_FIELD(u8_t _ttl);
|
||||
/* protocol*/
|
||||
|
|
|
@ -57,20 +57,19 @@ typedef s8_t err_t;
|
|||
#define ERR_INPROGRESS -5 /* Operation in progress */
|
||||
#define ERR_VAL -6 /* Illegal value. */
|
||||
#define ERR_WOULDBLOCK -7 /* Operation would block. */
|
||||
#define ERR_USE -8 /* Address in use. */
|
||||
#define ERR_ISCONN -9 /* Already connected. */
|
||||
|
||||
#define ERR_IS_FATAL(e) ((e) < ERR_WOULDBLOCK)
|
||||
#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN)
|
||||
|
||||
#define ERR_ABRT -8 /* Connection aborted. */
|
||||
#define ERR_RST -9 /* Connection reset. */
|
||||
#define ERR_CLSD -10 /* Connection closed. */
|
||||
#define ERR_CONN -11 /* Not connected. */
|
||||
#define ERR_ABRT -10 /* Connection aborted. */
|
||||
#define ERR_RST -11 /* Connection reset. */
|
||||
#define ERR_CLSD -12 /* Connection closed. */
|
||||
#define ERR_CONN -13 /* Not connected. */
|
||||
|
||||
#define ERR_ARG -12 /* Illegal argument. */
|
||||
#define ERR_ARG -14 /* Illegal argument. */
|
||||
|
||||
#define ERR_USE -13 /* Address in use. */
|
||||
|
||||
#define ERR_IF -14 /* Low-level netif error */
|
||||
#define ERR_ISCONN -15 /* Already connected. */
|
||||
#define ERR_IF -15 /* Low-level netif error */
|
||||
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
|
|
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
/** For release candidates, this is set to 1..254
|
||||
* For official releases, this is set to 255 (LWIP_RC_RELEASE)
|
||||
* For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */
|
||||
#define LWIP_VERSION_RC 2U
|
||||
#define LWIP_VERSION_RC 255U
|
||||
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
|
||||
#define LWIP_RC_RELEASE 255U
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef size_t mem_size_t;
|
|||
/* MEM_SIZE would have to be aligned, but using 64000 here instead of
|
||||
* 65535 leaves some room for alignment...
|
||||
*/
|
||||
#if MEM_SIZE > 64000l
|
||||
#if MEM_SIZE > 64000L
|
||||
typedef u32_t mem_size_t;
|
||||
#define MEM_SIZE_F U32_F
|
||||
#else
|
||||
|
|
|
@ -311,7 +311,7 @@
|
|||
* (requires NO_SYS==0)
|
||||
*/
|
||||
#ifndef MEMP_NUM_SYS_TIMEOUT
|
||||
#define MEMP_NUM_SYS_TIMEOUT 3000
|
||||
#define MEMP_NUM_SYS_TIMEOUT 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -229,7 +229,6 @@ u32_t sys_jiffies(void);
|
|||
|
||||
/** Returns the current time in milliseconds,
|
||||
* may be the same as sys_jiffies or at least based on it. */
|
||||
|
||||
u32_t sys_now(void);
|
||||
|
||||
/* Critical Region Protection */
|
||||
|
|
|
@ -228,7 +228,7 @@ struct tcp_pcb {
|
|||
u16_t acked;
|
||||
|
||||
u16_t snd_buf; /* Available buffer space for sending (in bytes). */
|
||||
#define TCP_SNDQUEUELEN_OVERFLOW (0xffff-3)
|
||||
#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3)
|
||||
u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */
|
||||
|
||||
#if TCP_OVERSIZE
|
||||
|
|
|
@ -278,7 +278,6 @@ PACK_STRUCT_END
|
|||
struct tcp_seg {
|
||||
struct tcp_seg *next; /* used when putting segements on a queue */
|
||||
struct pbuf *p; /* buffer containing data + TCP header */
|
||||
void *dataptr; /* pointer to the TCP data in the pbuf */
|
||||
u16_t len; /* the TCP length of this segment */
|
||||
#if TCP_OVERSIZE_DBGCHECK
|
||||
u16_t oversize_left; /* Extra bytes available at the end of the last
|
||||
|
|
|
@ -1,71 +1,100 @@
|
|||
/* This file specifies the lwip features */
|
||||
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
*/
|
||||
#define NO_SYS 0
|
||||
|
||||
/**
|
||||
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
|
||||
*/
|
||||
#define LWIP_SOCKET 1
|
||||
|
||||
/**
|
||||
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
|
||||
*/
|
||||
#define LWIP_NETCONN 1
|
||||
|
||||
/**
|
||||
* LWIP_DHCP==1: Enable DHCP module.
|
||||
*/
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
/**
|
||||
* DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
|
||||
*/
|
||||
#define DHCP_DOES_ARP_CHECK 0
|
||||
|
||||
/**
|
||||
* LWIP_TCP==1: Turn on TCP.
|
||||
*/
|
||||
#define LWIP_TCP 1
|
||||
|
||||
/**
|
||||
* LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only)
|
||||
*/
|
||||
#define LWIP_BROADCAST_PING 1
|
||||
|
||||
/**
|
||||
* LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only)
|
||||
*/
|
||||
#define LWIP_MULTICAST_PING 1
|
||||
|
||||
/**
|
||||
* LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
|
||||
*/
|
||||
#define LWIP_HAVE_LOOPIF 1
|
||||
|
||||
/* DEBUG options */
|
||||
#define LWIP_DEBUG 0
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||
#define SYS_DEBUG LWIP_DBG_OFF
|
||||
#define RAW_DEBUG LWIP_DBG_OFF
|
||||
#define MEM_DEBUG LWIP_DBG_OFF
|
||||
#define IP_DEBUG LWIP_DBG_OFF
|
||||
#define INET_DEBUG LWIP_DBG_OFF
|
||||
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||
|
||||
#define TCP_SND_BUF 2048
|
||||
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
|
||||
#define TCP_SND_QUEUELEN 40
|
||||
|
||||
#endif
|
||||
/* This file specifies the lwip features */
|
||||
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H_
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
*/
|
||||
#define NO_SYS 0
|
||||
|
||||
/**
|
||||
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
|
||||
*/
|
||||
#define LWIP_SOCKET 1
|
||||
|
||||
/**
|
||||
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
|
||||
*/
|
||||
#define LWIP_NETCONN 1
|
||||
|
||||
/**
|
||||
* LWIP_DHCP==1: Enable DHCP module.
|
||||
*/
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
/**
|
||||
* DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
|
||||
*/
|
||||
#define DHCP_DOES_ARP_CHECK 0
|
||||
|
||||
/**
|
||||
* ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be
|
||||
* updated with the source MAC and IP addresses supplied in the packet.
|
||||
* You may want to disable this if you do not trust LAN peers to have the
|
||||
* correct addresses, or as a limited approach to attempt to handle
|
||||
* spoofing. If disabled, lwIP will need to make a new ARP request if
|
||||
* the peer is not already in the ARP table, adding a little latency.
|
||||
* The peer *is* in the ARP table if it requested our address before.
|
||||
* Also notice that this slows down input processing of every IP packet!
|
||||
*/
|
||||
#define ETHARP_TRUST_IP_MAC 1
|
||||
|
||||
/**
|
||||
* LWIP_TCP==1: Turn on TCP.
|
||||
*/
|
||||
#define LWIP_TCP 1
|
||||
|
||||
/**
|
||||
* TCP_SND_BUF: TCP sender buffer space (bytes).
|
||||
*/
|
||||
#define TCP_SND_BUF 2048
|
||||
|
||||
/**
|
||||
* LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only)
|
||||
*/
|
||||
#define LWIP_BROADCAST_PING 1
|
||||
|
||||
/**
|
||||
* LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only)
|
||||
*/
|
||||
#define LWIP_MULTICAST_PING 1
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
|
||||
* (requires NO_SYS==0)
|
||||
*/
|
||||
#define MEMP_NUM_SYS_TIMEOUT 7
|
||||
|
||||
/**
|
||||
* LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
|
||||
*/
|
||||
#define LWIP_HAVE_LOOPIF 1
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
|
||||
* address equal to the netif IP address, looping them back up the stack.
|
||||
*/
|
||||
#define LWIP_NETIF_LOOPBACK 1
|
||||
|
||||
/**
|
||||
* LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from
|
||||
* application buffers to pbufs.
|
||||
*/
|
||||
#define LWIP_CHECKSUM_ON_COPY 1
|
||||
|
||||
/* DEBUG options */
|
||||
#define LWIP_DEBUG 1
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||
#define SYS_DEBUG LWIP_DBG_ON
|
||||
#define RAW_DEBUG LWIP_DBG_OFF
|
||||
#define MEM_DEBUG LWIP_DBG_OFF
|
||||
#define IP_DEBUG LWIP_DBG_OFF
|
||||
#define INET_DEBUG LWIP_DBG_OFF
|
||||
#define NETIF_DEBUG LWIP_DBG_ON
|
||||
#define TIMERS_DEBUG LWIP_DBG_ON
|
||||
|
||||
#endif
|
||||
|
|
|
@ -94,8 +94,8 @@ PACK_STRUCT_BEGIN
|
|||
* if 'type' in ethernet header is ETHTYPE_VLAN.
|
||||
* See IEEE802.Q */
|
||||
struct eth_vlan_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t tpid);
|
||||
PACK_STRUCT_FIELD(u16_t prio_vid);
|
||||
PACK_STRUCT_FIELD(u16_t tpid);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
|
@ -134,11 +134,11 @@ PACK_STRUCT_END
|
|||
/** 5 seconds period */
|
||||
#define ARP_TMR_INTERVAL 5000
|
||||
|
||||
#define ETHTYPE_ARP 0x0806
|
||||
#define ETHTYPE_IP 0x0800
|
||||
#define ETHTYPE_VLAN 0x8100
|
||||
#define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */
|
||||
#define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */
|
||||
#define ETHTYPE_ARP 0x0806U
|
||||
#define ETHTYPE_IP 0x0800U
|
||||
#define ETHTYPE_VLAN 0x8100U
|
||||
#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */
|
||||
#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */
|
||||
|
||||
/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
|
||||
* or known to be 32-bit aligned within the protocol header. */
|
||||
|
|
|
@ -1,53 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __NETIF_LOOPIF_H__
|
||||
#define __NETIF_LOOPIF_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
|
||||
#define loopif_poll netif_poll
|
||||
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
||||
|
||||
err_t loopif_init(struct netif *netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NETIF_LOOPIF_H__ */
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __NETIF_LOOPIF_H__
|
||||
#define __NETIF_LOOPIF_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
|
||||
#define loopif_poll netif_poll
|
||||
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
||||
|
||||
err_t loopif_init(struct netif *netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NETIF_LOOPIF_H__ */
|
||||
|
|
|
@ -628,7 +628,7 @@ etharp_ip_input(struct netif *netif, struct pbuf *p)
|
|||
ethhdr = (struct eth_hdr *)p->payload;
|
||||
iphdr = (struct ip_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR);
|
||||
#if ETHARP_SUPPORT_VLAN
|
||||
if (ethhdr->type == ETHTYPE_VLAN) {
|
||||
if (ethhdr->type == PP_HTONS(ETHTYPE_VLAN)) {
|
||||
iphdr = (struct ip_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR);
|
||||
}
|
||||
#endif /* ETHARP_SUPPORT_VLAN */
|
||||
|
@ -693,7 +693,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||
ethhdr = (struct eth_hdr *)p->payload;
|
||||
hdr = (struct etharp_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR);
|
||||
#if ETHARP_SUPPORT_VLAN
|
||||
if (ethhdr->type == ETHTYPE_VLAN) {
|
||||
if (ethhdr->type == PP_HTONS(ETHTYPE_VLAN)) {
|
||||
hdr = (struct etharp_hdr *)(((u8_t*)ethhdr) + SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR);
|
||||
}
|
||||
#endif /* ETHARP_SUPPORT_VLAN */
|
||||
|
@ -702,11 +702,10 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||
if ((hdr->hwtype != PP_HTONS(HWTYPE_ETHERNET)) ||
|
||||
(hdr->hwlen != ETHARP_HWADDR_LEN) ||
|
||||
(hdr->protolen != sizeof(ip_addr_t)) ||
|
||||
(hdr->proto != PP_HTONS(ETHTYPE_IP)) ||
|
||||
(ethhdr->type != PP_HTONS(ETHTYPE_ARP))) {
|
||||
(hdr->proto != PP_HTONS(ETHTYPE_IP))) {
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
|
||||
("etharp_arp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n",
|
||||
hdr->hwtype, hdr->hwlen, hdr->proto, hdr->protolen, ethhdr->type));
|
||||
("etharp_arp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n",
|
||||
hdr->hwtype, hdr->hwlen, hdr->proto, hdr->protolen));
|
||||
ETHARP_STATS_INC(etharp.proterr);
|
||||
ETHARP_STATS_INC(etharp.drop);
|
||||
pbuf_free(p);
|
||||
|
@ -1218,6 +1217,14 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
|||
{
|
||||
struct eth_hdr* ethhdr;
|
||||
u16_t type;
|
||||
s16_t ip_hdr_offset = SIZEOF_ETH_HDR;
|
||||
|
||||
if (p->len <= SIZEOF_ETH_HDR) {
|
||||
/* a packet with only an ethernet header (or less) is not valid for us */
|
||||
ETHARP_STATS_INC(etharp.proterr);
|
||||
ETHARP_STATS_INC(etharp.drop);
|
||||
goto free_and_return;
|
||||
}
|
||||
|
||||
/* points to packet payload, which starts with an Ethernet header */
|
||||
ethhdr = (struct eth_hdr *)p->payload;
|
||||
|
@ -1233,6 +1240,12 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
|||
#if ETHARP_SUPPORT_VLAN
|
||||
if (type == PP_HTONS(ETHTYPE_VLAN)) {
|
||||
struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr*)(((char*)ethhdr) + SIZEOF_ETH_HDR);
|
||||
if (p->len <= SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) {
|
||||
/* a packet with only an ethernet/vlan header (or less) is not valid for us */
|
||||
ETHARP_STATS_INC(etharp.proterr);
|
||||
ETHARP_STATS_INC(etharp.drop);
|
||||
goto free_and_return;
|
||||
}
|
||||
#ifdef ETHARP_VLAN_CHECK /* if not, allow all VLANs */
|
||||
if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) {
|
||||
/* silently ignore this packet: not for our VLAN */
|
||||
|
@ -1241,6 +1254,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
|||
}
|
||||
#endif /* ETHARP_VLAN_CHECK */
|
||||
type = vlan->tpid;
|
||||
ip_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR;
|
||||
}
|
||||
#endif /* ETHARP_SUPPORT_VLAN */
|
||||
|
||||
|
@ -1260,7 +1274,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
|||
etharp_ip_input(netif, p);
|
||||
#endif /* ETHARP_TRUST_IP_MAC */
|
||||
/* skip Ethernet header */
|
||||
if(pbuf_header(p, -(s16_t)SIZEOF_ETH_HDR)) {
|
||||
if(pbuf_header(p, -ip_hdr_offset)) {
|
||||
LWIP_ASSERT("Can't move over header in packet", 0);
|
||||
goto free_and_return;
|
||||
} else {
|
||||
|
|
|
@ -1,66 +1,66 @@
|
|||
/**
|
||||
* @file
|
||||
* Loop Interface
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_HAVE_LOOPIF
|
||||
|
||||
#include "netif/loopif.h"
|
||||
#include "lwip/snmp.h"
|
||||
|
||||
/**
|
||||
* Initialize a lwip network interface structure for a loopback interface
|
||||
*
|
||||
* @param netif the lwip network interface structure for this loopif
|
||||
* @return ERR_OK if the loopif is initialized
|
||||
* ERR_MEM if private data couldn't be allocated
|
||||
*/
|
||||
err_t
|
||||
loopif_init(struct netif *netif)
|
||||
{
|
||||
/* initialize the snmp variables and counters inside the struct netif
|
||||
* ifSpeed: no assumption can be made!
|
||||
*/
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0);
|
||||
|
||||
netif->name[0] = 'l';
|
||||
netif->name[1] = 'o';
|
||||
netif->output = netif_loop_output;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
#endif /* LWIP_HAVE_LOOPIF */
|
||||
/**
|
||||
* @file
|
||||
* Loop Interface
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_HAVE_LOOPIF
|
||||
|
||||
#include "netif/loopif.h"
|
||||
#include "lwip/snmp.h"
|
||||
|
||||
/**
|
||||
* Initialize a lwip network interface structure for a loopback interface
|
||||
*
|
||||
* @param netif the lwip network interface structure for this loopif
|
||||
* @return ERR_OK if the loopif is initialized
|
||||
* ERR_MEM if private data couldn't be allocated
|
||||
*/
|
||||
err_t
|
||||
loopif_init(struct netif *netif)
|
||||
{
|
||||
/* initialize the snmp variables and counters inside the struct netif
|
||||
* ifSpeed: no assumption can be made!
|
||||
*/
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0);
|
||||
|
||||
netif->name[0] = 'l';
|
||||
netif->name[1] = 'o';
|
||||
netif->output = netif_loop_output;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
#endif /* LWIP_HAVE_LOOPIF */
|
||||
|
|
|
@ -344,7 +344,9 @@ static void
|
|||
pppRecvWakeup(int pd)
|
||||
{
|
||||
PPPDEBUG(LOG_DEBUG, ("pppRecvWakeup: unit %d\n", pd));
|
||||
sio_read_abort(pppControl[pd].fd);
|
||||
if (pppControl[pd].openFlag != 0) {
|
||||
sio_read_abort(pppControl[pd].fd);
|
||||
}
|
||||
}
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
|
@ -363,7 +365,6 @@ pppLinkTerminated(int pd)
|
|||
PPPControl* pc;
|
||||
pppRecvWakeup(pd);
|
||||
pc = &pppControl[pd];
|
||||
pppDrop(&pc->rx); /* bug fix #17726 */
|
||||
|
||||
PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
|
||||
if (pc->linkStatusCB) {
|
||||
|
@ -439,7 +440,7 @@ pppInit(void)
|
|||
|
||||
magicInit();
|
||||
|
||||
subnetMask = PP_HTONL(0xffffff00);
|
||||
subnetMask = PP_HTONL(0xffffff00UL);
|
||||
|
||||
for (i = 0; i < NUM_PPP; i++) {
|
||||
/* Initialize each protocol to the standard option set. */
|
||||
|
@ -681,20 +682,8 @@ pppClose(int pd)
|
|||
void
|
||||
pppSigHUP(int pd)
|
||||
{
|
||||
#if PPPOE_SUPPORT
|
||||
PPPControl *pc = &pppControl[pd];
|
||||
if(pc->ethif) {
|
||||
PPPDEBUG(LOG_DEBUG, ("pppSigHUP: unit %d sig_hup -> pppHupCB\n", pd));
|
||||
pppHup(pd);
|
||||
} else
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
{
|
||||
#if PPPOS_SUPPORT
|
||||
PPPDEBUG(LOG_DEBUG, ("pppSigHUP: unit %d sig_hup -> pppHupCB\n", pd));
|
||||
pppHup(pd);
|
||||
pppRecvWakeup(pd);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
}
|
||||
PPPDEBUG(LOG_DEBUG, ("pppSigHUP: unit %d sig_hup -> pppHupCB\n", pd));
|
||||
pppHup(pd);
|
||||
}
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
|
@ -1809,6 +1798,7 @@ pppInProc(PPPControlRx *pcrx, u_char *s, int l)
|
|||
pppDrop(pcrx);
|
||||
/* Otherwise it's a good packet so pass it on. */
|
||||
} else {
|
||||
struct pbuf *inp;
|
||||
/* Trim off the checksum. */
|
||||
if(pcrx->inTail->len >= 2) {
|
||||
pcrx->inTail->len -= 2;
|
||||
|
@ -1827,18 +1817,20 @@ pppInProc(PPPControlRx *pcrx, u_char *s, int l)
|
|||
}
|
||||
|
||||
/* Dispatch the packet thereby consuming it. */
|
||||
inp = pcrx->inHead;
|
||||
/* Packet consumed, release our references. */
|
||||
pcrx->inHead = NULL;
|
||||
pcrx->inTail = NULL;
|
||||
#if PPP_INPROC_MULTITHREADED
|
||||
if(tcpip_callback_with_block(pppInput, pcrx->inHead, 0) != ERR_OK) {
|
||||
if(tcpip_callback_with_block(pppInput, inp, 0) != ERR_OK) {
|
||||
PPPDEBUG(LOG_ERR, ("pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pcrx->pd));
|
||||
pbuf_free(pcrx->inHead);
|
||||
pbuf_free(inp);
|
||||
LINK_STATS_INC(link.drop);
|
||||
snmp_inc_ifindiscards(&pppControl[pcrx->pd].netif);
|
||||
}
|
||||
#else /* PPP_INPROC_MULTITHREADED */
|
||||
pppInput(pcrx->inHead);
|
||||
pppInput(inp);
|
||||
#endif /* PPP_INPROC_MULTITHREADED */
|
||||
pcrx->inHead = NULL;
|
||||
pcrx->inTail = NULL;
|
||||
}
|
||||
|
||||
/* Prepare for a new packet. */
|
||||
|
@ -1912,10 +1904,12 @@ pppInProc(PPPControlRx *pcrx, u_char *s, int l)
|
|||
case PDDATA: /* Process data byte. */
|
||||
/* Make space to receive processed data. */
|
||||
if (pcrx->inTail == NULL || pcrx->inTail->len == PBUF_POOL_BUFSIZE) {
|
||||
if(pcrx->inTail) {
|
||||
if (pcrx->inTail != NULL) {
|
||||
pcrx->inTail->tot_len = pcrx->inTail->len;
|
||||
if (pcrx->inTail != pcrx->inHead) {
|
||||
pbuf_cat(pcrx->inHead, pcrx->inTail);
|
||||
/* give up the inTail reference now */
|
||||
pcrx->inTail = NULL;
|
||||
}
|
||||
}
|
||||
/* If we haven't started a packet, we need a packet header. */
|
||||
|
|
|
@ -90,7 +90,8 @@ create_arp_response(ip_addr_t *adr)
|
|||
|
||||
etharphdr->hwtype = htons(/*HWTYPE_ETHERNET*/ 1);
|
||||
etharphdr->proto = htons(ETHTYPE_IP);
|
||||
etharphdr->_hwlen_protolen = htons((ETHARP_HWADDR_LEN << 8) | sizeof(ip_addr_t));
|
||||
etharphdr->hwlen = ETHARP_HWADDR_LEN;
|
||||
etharphdr->protolen = sizeof(ip_addr_t);
|
||||
etharphdr->opcode = htons(ARP_REPLY);
|
||||
|
||||
SMEMCPY(ðarphdr->sipaddr, adr, sizeof(ip_addr_t));
|
||||
|
|
|
@ -88,7 +88,8 @@ tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip,
|
|||
memcpy((char*)tcphdr + sizeof(struct tcp_hdr), data, data_len);
|
||||
|
||||
/* calculate checksum */
|
||||
tcphdr->chksum = inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest),
|
||||
|
||||
tcphdr->chksum = inet_chksum_pseudo(p, src_ip, dst_ip,
|
||||
IP_PROTO_TCP, p->tot_len);
|
||||
|
||||
pbuf_header(p, sizeof(struct ip_hdr));
|
||||
|
@ -193,3 +194,20 @@ test_tcp_new_counters_pcb(struct test_tcp_counters* counters)
|
|||
}
|
||||
return pcb;
|
||||
}
|
||||
|
||||
/** Calls tcp_input() after adjusting current_iphdr_dest */
|
||||
void test_tcp_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
struct ip_hdr *iphdr = (struct ip_hdr*)p->payload;
|
||||
ip_addr_copy(current_iphdr_dest, iphdr->dest);
|
||||
ip_addr_copy(current_iphdr_src, iphdr->src);
|
||||
current_netif = inp;
|
||||
current_header = iphdr;
|
||||
|
||||
tcp_input(p, inp);
|
||||
|
||||
current_iphdr_dest.addr = 0;
|
||||
current_iphdr_src.addr = 0;
|
||||
current_netif = NULL;
|
||||
current_header = NULL;
|
||||
}
|
||||
|
|
|
@ -33,4 +33,6 @@ err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err
|
|||
|
||||
struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters);
|
||||
|
||||
void test_tcp_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -76,7 +76,7 @@ START_TEST(test_tcp_recv_inseq)
|
|||
EXPECT(p != NULL);
|
||||
if (p != NULL) {
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p, &netif);
|
||||
test_tcp_input(p, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 1);
|
||||
|
|
|
@ -180,7 +180,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||
EXPECT(p_fin != NULL);
|
||||
if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) {
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_8_9, &netif);
|
||||
test_tcp_input(p_8_9, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -192,7 +192,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_4_8, &netif);
|
||||
test_tcp_input(p_4_8, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -206,7 +206,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_4_10, &netif);
|
||||
test_tcp_input(p_4_10, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -220,7 +220,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_2_14, &netif);
|
||||
test_tcp_input(p_2_14, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -232,7 +232,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_fin, &netif);
|
||||
test_tcp_input(p_fin, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -244,7 +244,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(pinseq, &netif);
|
||||
test_tcp_input(pinseq, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 1);
|
||||
EXPECT(counters.recv_calls == 1);
|
||||
|
@ -330,7 +330,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL)
|
||||
&& (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) {
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_1_2, &netif);
|
||||
test_tcp_input(p_1_2, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -342,7 +342,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_4_8, &netif);
|
||||
test_tcp_input(p_4_8, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -356,7 +356,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_3_11, &netif);
|
||||
test_tcp_input(p_3_11, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -371,7 +371,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_2_12, &netif);
|
||||
test_tcp_input(p_2_12, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -385,7 +385,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(pinseq, &netif);
|
||||
test_tcp_input(pinseq, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 1);
|
||||
|
@ -394,7 +394,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT(pcb->ooseq == NULL);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_15_1, &netif);
|
||||
test_tcp_input(p_15_1, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 1);
|
||||
|
@ -406,7 +406,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_15_1a, &netif);
|
||||
test_tcp_input(p_15_1a, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 1);
|
||||
|
@ -418,7 +418,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||
EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
|
||||
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(pinseqFIN, &netif);
|
||||
test_tcp_input(pinseqFIN, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 1);
|
||||
EXPECT(counters.recv_calls == 2);
|
||||
|
@ -480,7 +480,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
|
|||
TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
|
||||
EXPECT(p != NULL);
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p, &netif);
|
||||
test_tcp_input(p, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -504,7 +504,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
|
|||
p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
|
||||
EXPECT(p_ovr != NULL);
|
||||
/* pass the segment to tcp_input */
|
||||
tcp_input(p_ovr, &netif);
|
||||
test_tcp_input(p_ovr, &netif);
|
||||
/* check if counters are as expected */
|
||||
EXPECT(counters.close_calls == 0);
|
||||
EXPECT(counters.recv_calls == 0);
|
||||
|
@ -516,7 +516,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
|
|||
EXPECT_OOSEQ(datalen == datalen2);
|
||||
|
||||
/* now pass inseq */
|
||||
tcp_input(pinseq, &netif);
|
||||
test_tcp_input(pinseq, &netif);
|
||||
EXPECT(pcb->ooseq == NULL);
|
||||
|
||||
/* make sure the pcb is freed */
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
*
|
||||
* Set whole address space as occupied
|
||||
*/
|
||||
static uint8_t bitmap[BITMAP_SIZE] = {[0 ... BITMAP_SIZE-1] = 0xFF};
|
||||
static uint8_t bitmap[BITMAP_SIZE]; // = {[0 ... BITMAP_SIZE-1] = 0xFF};
|
||||
static spinlock_t bitmap_lock = SPINLOCK_INIT;
|
||||
static size_t alloc_start;
|
||||
atomic_int32_t total_pages = ATOMIC_INIT(0);
|
||||
|
@ -94,6 +94,9 @@ int mmu_init(void)
|
|||
unsigned int i;
|
||||
size_t addr;
|
||||
|
||||
// at first, set default value of the bitmap
|
||||
memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE);
|
||||
|
||||
#ifdef CONFIG_MULTIBOOT
|
||||
if (mb_info && (mb_info->flags & MULTIBOOT_INFO_MEM_MAP)) {
|
||||
size_t end_addr;
|
||||
|
|
0
newlib/src/compile
Normal file → Executable file
0
newlib/src/compile
Normal file → Executable file
0
newlib/src/config.guess
vendored
Normal file → Executable file
0
newlib/src/config.guess
vendored
Normal file → Executable file
0
newlib/src/config.rpath
Normal file → Executable file
0
newlib/src/config.rpath
Normal file → Executable file
0
newlib/src/config.status
Normal file → Executable file
0
newlib/src/config.status
Normal file → Executable file
0
newlib/src/config.sub
vendored
Normal file → Executable file
0
newlib/src/config.sub
vendored
Normal file → Executable file
0
newlib/src/config/acinclude.m4
Normal file → Executable file
0
newlib/src/config/acinclude.m4
Normal file → Executable file
0
newlib/src/depcomp
Normal file → Executable file
0
newlib/src/depcomp
Normal file → Executable file
0
newlib/src/etc/config.status
Normal file → Executable file
0
newlib/src/etc/config.status
Normal file → Executable file
0
newlib/src/etc/configure
vendored
Normal file → Executable file
0
newlib/src/etc/configure
vendored
Normal file → Executable file
0
newlib/src/install-sh
Normal file → Executable file
0
newlib/src/install-sh
Normal file → Executable file
0
newlib/src/libgloss/bfin/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/bfin/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/cris/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/cris/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/crx/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/crx/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/d30v/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/d30v/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/doc/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/doc/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/fr30/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/fr30/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/frv/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/frv/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/hp74x/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/hp74x/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/i386/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/i386/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/i960/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/i960/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/iq2000/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/iq2000/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/libnosys/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/libnosys/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/lm32/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/lm32/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m32c/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m32c/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m32r/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m32r/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m68hc11/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m68hc11/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m68k/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/m68k/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mcore/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mcore/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mep/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mep/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/metalsvm/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/metalsvm/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mips/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mips/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mn10200/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mn10200/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mn10300/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mn10300/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mt/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/mt/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/pa/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/pa/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/rs6000/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/rs6000/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/sparc/configure
vendored
Normal file → Executable file
0
newlib/src/libgloss/sparc/configure
vendored
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue