Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

This commit was generated by cvs2svn to compensate for changes in r4,

which included commits to RCS files with non-trunk default branches.


git-svn-id: https://devkitpro.svn.sourceforge.net/svnroot/devkitpro/trunk/libogc@3 258c5a1a-4f63-435d-9564-e8f6d34ab52c
  • Loading branch information...
commit 391f2b2940cda2edde4b4827fce455ba38919efe 0 parents
wntrmute authored
Showing with 58,856 additions and 0 deletions.
  1. +201 −0 Makefile
  2. +25 −0 gc/debug.h
  3. +34 −0 gc/gccore.h
  4. +44 −0 gc/gcmodplay.h
  5. +84 −0 gc/gctypes.h
  6. +111 −0 gc/ipv4/lwip/icmp.h
  7. +84 −0 gc/ipv4/lwip/inet.h
  8. +155 −0 gc/ipv4/lwip/ip.h
  9. +141 −0 gc/ipv4/lwip/ip_addr.h
  10. +46 −0 gc/ipv4/lwip/ip_frag.h
  11. +159 −0 gc/lwip/api.h
  12. +94 −0 gc/lwip/api_msg.h
  13. +216 −0 gc/lwip/arch.h
  14. +87 −0 gc/lwip/debug.h
  15. +47 −0 gc/lwip/def.h
  16. +212 −0 gc/lwip/dhcp.h
  17. +70 −0 gc/lwip/err.h
  18. +221 −0 gc/lwip/lwipopts.h
  19. +61 −0 gc/lwip/mem.h
  20. +63 −0 gc/lwip/memp.h
  21. +143 −0 gc/lwip/netif.h
  22. +642 −0 gc/lwip/opt.h
  23. +116 −0 gc/lwip/pbuf.h
  24. +74 −0 gc/lwip/raw.h
  25. +63 −0 gc/lwip/sio.h
  26. +178 −0 gc/lwip/snmp.h
  27. +261 −0 gc/lwip/sockets.h
  28. +158 −0 gc/lwip/stats.h
  29. +183 −0 gc/lwip/sys.h
  30. +533 −0 gc/lwip/tcp.h
  31. +68 −0 gc/lwip/tcpip.h
  32. +104 −0 gc/lwip/udp.h
  33. +49 −0 gc/mad/bit.h
  34. +130 −0 gc/mad/config.h
  35. +92 −0 gc/mad/decoder.h
  36. +486 −0 gc/mad/fixed.h
  37. +119 −0 gc/mad/frame.h
  38. +59 −0 gc/mad/global.h
  39. +68 −0 gc/mad/huffman.h
  40. +31 −0 gc/mad/layer12.h
  41. +30 −0 gc/mad/layer3.h
  42. +948 −0 gc/mad/mad.h
  43. +108 −0 gc/mad/stream.h
  44. +70 −0 gc/mad/synth.h
  45. +102 −0 gc/mad/timer.h
  46. +49 −0 gc/mad/version.h
  47. +16 −0 gc/madplayer.h
  48. +143 −0 gc/modplay.h
  49. +35 −0 gc/modplay/bpmtab.h
  50. +98 −0 gc/modplay/defines.h
  51. +34 −0 gc/modplay/freqtab.h
  52. +36 −0 gc/modplay/inctab.h
  53. +38 −0 gc/modplay/mixer.h
  54. +34 −0 gc/modplay/semitonetab.h
  55. +65 −0 gc/netif/arch/cc.h
  56. +40 −0 gc/netif/arch/cpu.h
  57. +47 −0 gc/netif/arch/init.h
  58. +43 −0 gc/netif/arch/lib.h
  59. +41 −0 gc/netif/arch/perf.h
  60. +54 −0 gc/netif/arch/sys_arch.h
  61. +98 −0 gc/netif/etharp.h
  62. +42 −0 gc/netif/gcif/gcif.h
  63. +39 −0 gc/netif/loopif.h
  64. +239 −0 gc/network.h
  65. +41 −0 gc/ogc/aram.h
  66. +48 −0 gc/ogc/audio.h
  67. +54 −0 gc/ogc/cache.h
  68. +141 −0 gc/ogc/card.h
  69. +47 −0 gc/ogc/cast.h
  70. +24 −0 gc/ogc/cond.h
  71. +50 −0 gc/ogc/context.h
  72. +44 −0 gc/ogc/dsp.h
  73. +19 −0 gc/ogc/dvd.h
  74. +16 −0 gc/ogc/exception.h
  75. +51 −0 gc/ogc/exi.h
  76. +166 −0 gc/ogc/gu.h
  77. +1,037 −0 gc/ogc/gx.h
  78. +30 −0 gc/ogc/gx_struct.h
  79. +95 −0 gc/ogc/irq.h
  80. +36 −0 gc/ogc/lwp.h
  81. +76 −0 gc/ogc/lwp_messages.h
  82. +74 −0 gc/ogc/lwp_mutex.h
  83. +31 −0 gc/ogc/lwp_priority.h
  84. +39 −0 gc/ogc/lwp_queue.h
  85. +42 −0 gc/ogc/lwp_sema.h
  86. +25 −0 gc/ogc/lwp_stack.h
  87. +46 −0 gc/ogc/lwp_states.h
  88. +37 −0 gc/ogc/lwp_threadq.h
  89. +91 −0 gc/ogc/lwp_threads.h
  90. +38 −0 gc/ogc/lwp_tqdata.h
  91. +53 −0 gc/ogc/lwp_watchdog.h
  92. +245 −0 gc/ogc/machine/asm.h
  93. +97 −0 gc/ogc/machine/processor.h
  94. +193 −0 gc/ogc/machine/spinlock.h
  95. +30 −0 gc/ogc/message.h
  96. +24 −0 gc/ogc/mutex.h
  97. +77 −0 gc/ogc/pad.h
  98. +21 −0 gc/ogc/semaphore.h
  99. +25 −0 gc/ogc/sys_state.h
  100. +55 −0 gc/ogc/system.h
  101. +43 −0 gc/ogc/video.h
  102. +58 −0 gc/ogc/video_types.h
  103. +21 −0 gc/ogcsys.h
  104. +1,120 −0 gcsdk.dsp
  105. +29 −0 gcsdk.dsw
  106. +3 −0  install.sh
  107. +533 −0 libdb/debug.c
  108. +155 −0 libdb/debug_handler.S
  109. +607 −0 libmad/D.dat
  110. +237 −0 libmad/bit.c
  111. +582 −0 libmad/decoder.c
  112. +81 −0 libmad/fixed.c
  113. +502 −0 libmad/frame.c
  114. +3,098 −0 libmad/huffman.c
  115. +62 −0 libmad/imdct_s.dat
  116. +510 −0 libmad/layer12.c
  117. +2,502 −0 libmad/layer3.c
  118. +119 −0 libmad/madplayer.c
  119. +77 −0 libmad/qc_table.dat
  120. +8,747 −0 libmad/rq_table.dat
  121. +106 −0 libmad/sf_table.dat
  122. +160 −0 libmad/stream.c
  123. +857 −0 libmad/synth.c
  124. +486 −0 libmad/timer.c
  125. +91 −0 libmad/version.c
  126. +228 −0 libmodplay/bpmtab32.c
  127. +228 −0 libmodplay/bpmtab48.c
  128. +44 −0 libmodplay/freqtab.c
  129. +317 −0 libmodplay/gcmodplay.c
  130. +4,102 −0 libmodplay/inctab32.c
  131. +4,102 −0 libmodplay/inctab48.c
  132. +219 −0 libmodplay/mixer.c
  133. +1,109 −0 libmodplay/modplay.c
  134. +4,129 −0 libmodplay/semitonetab.c
  135. +209 −0 libogc.dox
  136. +107 −0 libogc.prj
  137. +370 −0 libogc/aram.c
  138. +318 −0 libogc/audio.c
  139. +111 −0 libogc/cache.c
  140. +372 −0 libogc/cache_asm.S
  141. +669 −0 libogc/card.c
  142. +128 −0 libogc/cond.c
  143. +38 −0 libogc/decrementer.c
  144. +191 −0 libogc/decrementer_handler.S
  145. +281 −0 libogc/depackrnc.S
  146. +75 −0 libogc/dsp.c
  147. +78 −0 libogc/dvd.c
  148. +153 −0 libogc/exception.c
  149. +148 −0 libogc/exception_handler.S
  150. +526 −0 libogc/exi.c
  151. +32 −0 libogc/exi_asm.S
  152. +592 −0 libogc/gu.c
  153. +588 −0 libogc/gu_psasm.S
  154. +3,801 −0 libogc/gx.c
  155. +418 −0 libogc/irq.c
  156. +191 −0 libogc/irq_handler.S
  157. +167 −0 libogc/lwp.c
  158. +436 −0 libogc/lwp_handler.S
  159. +258 −0 libogc/lwp_messages.c
  160. +56 −0 libogc/lwp_messages.inl
  161. +95 −0 libogc/lwp_mutex.c
  162. +88 −0 libogc/lwp_mutex.inl
  163. +14 −0 libogc/lwp_priority.c
  164. +49 −0 libogc/lwp_priority.inl
  165. +68 −0 libogc/lwp_queue.c
  166. +113 −0 libogc/lwp_queue.inl
  167. +63 −0 libogc/lwp_sema.c
  168. +38 −0 libogc/lwp_sema.inl
  169. +26 −0 libogc/lwp_stack.c
  170. +14 −0 libogc/lwp_stack.inl
  171. +109 −0 libogc/lwp_states.inl
  172. +498 −0 libogc/lwp_threadq.c
  173. +9 −0 libogc/lwp_threadq.inl
  174. +638 −0 libogc/lwp_threads.c
  175. +78 −0 libogc/lwp_threads.inl
Sorry, we could not display the entire diff because it was too big.
201 Makefile
@@ -0,0 +1,201 @@
+.SUFFIXES:
+
+#---------------------------------------------------------------------------------
+ifeq ($(USERNAME),davem)
+#---------------------------------------------------------------------------------
+export PATH:=/c/devkitPPC_r8/bin:/bin
+PREFIX := powerpc-elf-
+#---------------------------------------------------------------------------------
+else
+#---------------------------------------------------------------------------------
+PREFIX := powerpc-eabi-elf-
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
+
+
+
+CC := $(PREFIX)gcc
+CXX := $(PREFIX)g++
+AS := $(PREFIX)as
+AR := $(PREFIX)ar
+LD := $(PREFIX)ld
+OBJCOPY := $(PREFIX)objcopy
+
+BUILD := build
+#---------------------------------------------------------------------------------
+ifneq ($(BUILD),$(notdir $(CURDIR)))
+#---------------------------------------------------------------------------------
+export BASEDIR := $(CURDIR)
+export BUILDDIR := $(BASEDIR)/$(BUILD)
+export LIBDIR := $(BASEDIR)/lib
+export LWIPDIR := $(BASEDIR)/lwip
+export OGCDIR := $(BASEDIR)/libogc
+export MODDIR := $(BASEDIR)/libmodplay
+export MADDIR := $(BASEDIR)/libmad
+export DBDIR := $(BASEDIR)/libdb
+export GCSYSDIR := $(BASEDIR)/libogcsys
+
+export DEPSDIR := $(BASEDIR)/deps
+export INCDIR := $(BASEDIR)/include
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
+
+#---------------------------------------------------------------------------------
+BBALIB := $(LIBDIR)/libbba
+OGCLIB := $(LIBDIR)/libogc
+MODLIB := $(LIBDIR)/libmodplay
+MADLIB := $(LIBDIR)/libmad
+DBLIB := $(LIBDIR)/libdb
+GCSYSLIB := $(LIBDIR)/libogcsys
+
+#---------------------------------------------------------------------------------
+DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
+INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
+ -I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine -I$(BASEDIR)/gc/modplay -I$(BASEDIR)/gc/mad
+
+MACHDEP := -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float
+CFLAGS := -DGAMECUBE -O2 $(MACHDEP) -Wall $(INCLUDES)
+LDFLAGS :=
+
+#---------------------------------------------------------------------------------
+VPATH := $(LWIPDIR) \
+ $(LWIPDIR)/arch/gc \
+ $(LWIPDIR)/arch/gc/netif \
+ $(LWIPDIR)/core \
+ $(LWIPDIR)/core/ipv4 \
+ $(LWIPDIR)/netif \
+ $(OGCDIR) \
+ $(MODDIR) \
+ $(MADDIR) \
+ $(DBDIR) \
+ $(GCSYSDIR)
+
+
+#---------------------------------------------------------------------------------
+LWIPOBJ := network.o netio.o gcif.o lib_arch.o \
+ inet.o mem.o dhcp.o raw.o \
+ memp.o netif.o pbuf.o stats.o \
+ sys.o tcp.o tcp_in.o tcp_out.o \
+ udp.o icmp.o ip.o ip_frag.o \
+ ip_addr.o etharp.o loopif.o
+
+#---------------------------------------------------------------------------------
+OGCOBJ := lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
+ lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
+ lwp_watchdog.o sys_state.o \
+ exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
+ video_asm.o video.o pad.o dvd.o exi.o mutex.o \
+ cache_asm.o system.o exi_asm.o system_asm.o cond.o \
+ gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
+ message.o card.o aram.o depackrnc.o decrementer_handler.o \
+ dsp.o ogc_crt0.o
+
+#---------------------------------------------------------------------------------
+MODOBJ := freqtab.o mixer.o modplay.o semitonetab.o gcmodplay.o \
+ bpmtab32.o bpmtab48.o \
+ inctab32.o inctab48.o
+
+#---------------------------------------------------------------------------------
+MADOBJ := bit.o decoder.o fixed.o frame.o huffman.o \
+ layer12.o layer3.o stream.o synth.o timer.o \
+ version.o madplayer.o
+
+#---------------------------------------------------------------------------------
+DBOBJ := debug_handler.o debug.o
+
+#---------------------------------------------------------------------------------
+GCSYSOBJ := newlibc.o sbrk.o open.o write.o close.o \
+ getpid.o kill.o isatty.o fstat.o read.o \
+ lseek.o sleep.o usleep.o timesupp.o \
+ malloc_lock.o console.o console_font.o \
+ console_font_8x8.o iosupp.o netio_fake.o \
+ stdin_fake.o
+
+#---------------------------------------------------------------------------------
+# Build rules:
+#---------------------------------------------------------------------------------
+%.o : %.c
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
+
+#---------------------------------------------------------------------------------
+%.o : %.cpp
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
+
+#---------------------------------------------------------------------------------
+%.o : %.S
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(CC) -MMD -MF $(DEPSDIR)/$*.d $(CFLAGS) -D_LANGUAGE_ASSEMBLY -c $< -o $@
+
+#---------------------------------------------------------------------------------
+%.o : %.s
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(AS) -mppc -Qy $< -o $(OBJDIR)/$@
+
+#---------------------------------------------------------------------------------
+%.a:
+#---------------------------------------------------------------------------------
+ $(AR) -rc $@ $^
+
+#---------------------------------------------------------------------------------
+all:
+#---------------------------------------------------------------------------------
+ @[ -d $(LIBDIR) ] || mkdir -p $(LIBDIR)
+ @[ -d $(DEPSDIR) ] || mkdir -p $(DEPSDIR)
+ @[ -d $(BUILDDIR) ] || mkdir -p $(BUILDDIR)
+ @make libs -C $(BUILDDIR) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+$(BBALIB).a: $(LWIPOBJ)
+#---------------------------------------------------------------------------------
+$(OGCLIB).a: $(OGCOBJ)
+#---------------------------------------------------------------------------------
+$(MP3LIB).a: $(MP3OBJ)
+#---------------------------------------------------------------------------------
+$(MODLIB).a: $(MODOBJ)
+#---------------------------------------------------------------------------------
+$(MADLIB).a: $(MADOBJ)
+#---------------------------------------------------------------------------------
+$(DBLIB).a: $(DBOBJ)
+#---------------------------------------------------------------------------------
+$(GCSYSLIB).a: $(GCSYSOBJ)
+#---------------------------------------------------------------------------------
+
+.PHONEY: libs install dist
+
+#---------------------------------------------------------------------------------
+install:
+#---------------------------------------------------------------------------------
+ @mkdir -p $(INCDIR)
+ @mkdir -p $(INCDIR)/ogc
+ @mkdir -p $(INCDIR)/modplay
+ @mkdir -p $(INCDIR)/mad
+ cp ./gc/*.h $(INCDIR)
+ cp ./gc/ogc/*.h $(INCDIR)/ogc
+ cp ./gc/modplay/*.h $(INCDIR)/modplay
+ cp ./gc/mad/*.h $(INCDIR)/mad
+
+#---------------------------------------------------------------------------------
+dist:
+#---------------------------------------------------------------------------------
+ tar -cjf libogc.tar.bz2 include lib
+
+#---------------------------------------------------------------------------------
+libs: $(OGCLIB).a $(BBALIB).a $(MODLIB).a $(MADLIB).a $(DBLIB).a $(GCSYSLIB).a
+#---------------------------------------------------------------------------------
+
+#---------------------------------------------------------------------------------
+clean:
+#---------------------------------------------------------------------------------
+ rm -fr $(BUILDDIR)
+ rm -fr $(DEPSDIR)
+ rm -f *.map
+
+-include $(DEPSDIR)/*.d
25 gc/debug.h
@@ -0,0 +1,25 @@
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+#include <gctypes.h>
+
+#define GDBSTUB_PORT 2828
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+typedef struct _ptregs {
+ u32 gpr[32];
+ f64 fpr[32];
+ u32 pc, ps, cnd, lr;
+ u32 cnt, xer, mq;
+} pt_regs;
+
+void DEBUG_Init(u32 port);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
34 gc/gccore.h
@@ -0,0 +1,34 @@
+#ifndef __GCCORE_H__
+#define __GCCORE_H__
+
+#include "ogc/aram.h"
+#include "ogc/audio.h"
+#include "ogc/cache.h"
+#include "ogc/card.h"
+#include "ogc/cast.h"
+#include "ogc/exi.h"
+#include "ogc/gu.h"
+#include "ogc/gx.h"
+#include "ogc/gx_struct.h"
+#include "ogc/irq.h"
+#include "ogc/lwp.h"
+#include "ogc/message.h"
+#include "ogc/semaphore.h"
+#include "ogc/pad.h"
+#include "ogc/system.h"
+#include "ogc/video.h"
+#include "ogc/video_types.h"
+
+#define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v)))
+
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+void depackrnc(void *src,void *dst);
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+
+#endif
44 gc/gcmodplay.h
@@ -0,0 +1,44 @@
+#ifndef __GCMODPLAY_H__
+#define __GCMODPLAY_H__
+
+#include <gctypes.h>
+#include <modplay.h>
+
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _modsndbuf {
+ u32 freq;
+ u16 fmt;
+ u32 chans;
+ f32 samples;
+ u32 data_len;
+ void *usr_data;
+ void (*callback)(void *,u8 *,u32);
+} MODSNDBUF;
+
+typedef struct _modplay {
+ MOD mod;
+ BOOL playing,paused;
+ BOOL bits,stereo,manual_polling;
+ u32 playfreq,numSFXChans;
+ MODSNDBUF soundBuf;
+} MODPlay;
+
+void MODPlay_Init(MODPlay *mod);
+u32 MODPlay_SetFrequency(MODPlay *mod,u32 freq);
+void MODPlay_SetStereo(MODPlay *mod,BOOL stereo);
+u32 MODPlay_SetMOD(MODPlay *mod,u8 *mem);
+void MODPlay_Unload(MODPlay *mod);
+u32 MODPlay_AllocSFXChannels(MODPlay *mod,u32 sfxchans);
+u32 MODPlay_Start(MODPlay *mod);
+u32 MODPlay_Stop(MODPlay *mod);
+u32 MODPlay_TriggerNote(MODPlay *mod,u32 chan,u8 inst,u16 freq,u8 vol);
+u32 MODPlay_Pause(MODPlay *mod,BOOL);
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+
+#endif
84 gc/gctypes.h
@@ -0,0 +1,84 @@
+#ifndef __GCTYPES_H__
+#define __GCTYPES_H__
+/*+----------------------------------------------------------------------------------------------+*/
+// typedef's borrowed from the HAM development kit for Gameboy Advance
+// See www.ngine.de for information about this fantastic devkit!
+/*+----------------------------------------------------------------------------------------------+*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+// bool is a standard type in cplusplus, but not in c.
+#ifndef __cplusplus
+typedef unsigned char bool; ///< For c++ compatibility
+#endif
+/*+----------------------------------------------------------------------------------------------+*/
+typedef unsigned char u8; ///< 8bit unsigned integer
+typedef unsigned short u16; ///< 16bit unsigned integer
+typedef unsigned int u32; ///< 32bit unsigned integer
+typedef unsigned long long u64; ///< 64bit unsigned integer
+/*+----------------------------------------------------------------------------------------------+*/
+typedef signed char s8; ///< 8bit signed integer
+typedef signed short s16; ///< 16bit signed integer
+typedef signed int s32; ///< 32bit signed integer
+typedef signed long long s64; ///< 64bit signed integer
+/*+----------------------------------------------------------------------------------------------+*/
+typedef volatile unsigned char vu8; ///< 8bit unsigned volatile't integer
+typedef volatile unsigned short vu16; ///< 16bit unsigned volatile't integer
+typedef volatile unsigned int vu32; ///< 32bit unsigned volatile't integer
+typedef volatile unsigned long long vu64; ///< 64bit unsigned volatile't integer
+/*+----------------------------------------------------------------------------------------------+*/
+typedef volatile signed char vs8; ///< 8bit signed volatile't integer
+typedef volatile signed short vs16; ///< 16bit signed volatile't integer
+typedef volatile signed int vs32; ///< 32bit signed volatile't integer
+typedef volatile signed long long vs64; ///< 64bit signed volatile't integer
+/*+----------------------------------------------------------------------------------------------+*/
+// fixed point math typedefs
+typedef s16 sfp16; ///< 1:7:8 fixed point
+typedef s32 sfp32; ///< 1:19:8 fixed point
+typedef u16 ufp16; ///< 8:8 fixed point
+typedef u32 ufp32; ///< 24:8 fixed point
+/*+----------------------------------------------------------------------------------------------+*/
+typedef float f32;
+typedef double f64;
+/*+----------------------------------------------------------------------------------------------+*/
+typedef volatile float vf32;
+typedef volatile double vf64;
+/*+----------------------------------------------------------------------------------------------+*/
+typedef unsigned int BOOL;
+/*+----------------------------------------------------------------------------------------------+*/
+// alias type typedefs
+#define FIXED s32 ///< Alias type for sfp32
+/*+----------------------------------------------------------------------------------------------+*/
+// boolean defines
+#ifndef boolean
+#define boolean u8
+#endif
+/*+----------------------------------------------------------------------------------------------+*/
+#ifndef TRUE
+#define TRUE 1 ///< True
+#endif
+/*+----------------------------------------------------------------------------------------------+*/
+#ifndef FALSE
+#define FALSE 0 ///< False
+#endif
+/*+----------------------------------------------------------------------------------------------+*/
+#ifndef __cplusplus
+#define true TRUE ///< For c++ compatibility
+#define false FALSE ///< For c++ compatibility
+#endif
+/*+----------------------------------------------------------------------------------------------+*/
+#ifndef NULL
+#define NULL 0 ///< Pointer to 0
+#endif
+/*+----------------------------------------------------------------------------------------------+*/
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+
+#endif /* TYPES_H */
+
+
+/* END OF FILE */
111 gc/ipv4/lwip/icmp.h
@@ -0,0 +1,111 @@
+/*
+ * 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 __LWIP_ICMP_H__
+#define __LWIP_ICMP_H__
+
+#include "lwip/arch.h"
+
+#include "lwip/opt.h"
+#include "lwip/pbuf.h"
+
+#include "lwip/netif.h"
+
+#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_TSR 14 /* timestamp reply */
+#define ICMP_IRQ 15 /* information request */
+#define ICMP_IR 16 /* information reply */
+
+enum icmp_dur_type {
+ 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 */
+};
+
+enum icmp_te_type {
+ ICMP_TE_TTL = 0, /* time to live exceeded in transit */
+ ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
+};
+
+void icmp_input(struct pbuf *p, struct netif *inp);
+
+void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
+void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
+
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/bpstruct.h"
+#endif
+PACK_STRUCT_BEGIN
+struct icmp_echo_hdr {
+ PACK_STRUCT_FIELD(u16_t _type_code);
+ PACK_STRUCT_FIELD(u16_t chksum);
+ PACK_STRUCT_FIELD(u16_t id);
+ PACK_STRUCT_FIELD(u16_t seqno);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+
+PACK_STRUCT_BEGIN
+struct icmp_dur_hdr {
+ PACK_STRUCT_FIELD(u16_t _type_code);
+ PACK_STRUCT_FIELD(u16_t chksum);
+ PACK_STRUCT_FIELD(u32_t unused);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+
+PACK_STRUCT_BEGIN
+struct icmp_te_hdr {
+ PACK_STRUCT_FIELD(u16_t _type_code);
+ PACK_STRUCT_FIELD(u16_t chksum);
+ PACK_STRUCT_FIELD(u32_t unused);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/epstruct.h"
+#endif
+
+#define ICMPH_TYPE(hdr) (ntohs((hdr)->_type_code) >> 8)
+#define ICMPH_CODE(hdr) (ntohs((hdr)->_type_code) & 0xff)
+
+#define ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = htons(ICMPH_CODE(hdr) | ((type) << 8)))
+#define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8)))
+
+#endif /* __LWIP_ICMP_H__ */
+
84 gc/ipv4/lwip/inet.h
@@ -0,0 +1,84 @@
+/*
+ * 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 __LWIP_INET_H__
+#define __LWIP_INET_H__
+
+#include "lwip/arch.h"
+
+#include "lwip/opt.h"
+#include "lwip/pbuf.h"
+#include "lwip/ip_addr.h"
+
+u16_t inet_chksum(void *dataptr, u16_t len);
+u16_t inet_chksum_pbuf(struct pbuf *p);
+u16_t inet_chksum_pseudo(struct pbuf *p,
+ struct ip_addr *src, struct ip_addr *dest,
+ u8_t proto, u16_t proto_len);
+
+u32_t inet_addr(const char *cp);
+int inet_aton(const char *cp, struct in_addr *addr);
+char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
+
+#ifdef htons
+#undef htons
+#endif /* htons */
+#ifdef htonl
+#undef htonl
+#endif /* htonl */
+#ifdef ntohs
+#undef ntohs
+#endif /* ntohs */
+#ifdef ntohl
+#undef ntohl
+#endif /* ntohl */
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define htons(x) (x)
+#define ntohs(x) (x)
+#define htonl(x) (x)
+#define ntohl(x) (x)
+#else
+#ifdef LWIP_PREFIX_BYTEORDER_FUNCS
+/* workaround for naming collisions on some platforms */
+#define htons lwip_htons
+#define ntohs lwip_ntohs
+#define htonl lwip_htonl
+#define ntohl lwip_ntohl
+#endif
+u16_t htons(u16_t x);
+u16_t ntohs(u16_t x);
+u32_t htonl(u32_t x);
+u32_t ntohl(u32_t x);
+#endif
+
+#endif /* __LWIP_INET_H__ */
+
155 gc/ipv4/lwip/ip.h
@@ -0,0 +1,155 @@
+/*
+ * 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 __LWIP_IP_H__
+#define __LWIP_IP_H__
+
+#include "lwip/arch.h"
+
+#include "lwip/def.h"
+#include "lwip/pbuf.h"
+#include "lwip/ip_addr.h"
+
+#include "lwip/err.h"
+
+struct netif;
+
+void ip_init(void);
+struct netif *ip_route(struct ip_addr *dest);
+err_t ip_input(struct pbuf *p, struct netif *inp);
+err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
+ u8_t ttl, u8_t tos, u8_t proto);
+err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
+ u8_t ttl, u8_t tos, u8_t proto,
+ struct netif *netif);
+
+#define IP_HLEN 20
+
+#define IP_PROTO_ICMP 1
+#define IP_PROTO_UDP 17
+#define IP_PROTO_UDPLITE 170
+#define IP_PROTO_TCP 6
+
+/* This is passed as the destination address to ip_output_if (not
+ to ip_output), meaning that an IP header already is constructed
+ in the pbuf. This is used when TCP retransmits. */
+#ifdef IP_HDRINCL
+#undef IP_HDRINCL
+#endif /* IP_HDRINCL */
+#define IP_HDRINCL NULL
+
+
+/* This is the common part of all PCB types. It needs to be at the
+ beginning of a PCB type definition. It is located here so that
+ changes to this common part are made in one location instead of
+ having to change all PCB structs. */
+#define IP_PCB struct ip_addr local_ip; \
+ struct ip_addr remote_ip; \
+ /* Socket options */ \
+ u16_t so_options; \
+ /* Type Of Service */ \
+ u8_t tos; \
+ /* Time To Live */ \
+ u8_t ttl
+
+/*
+ * Option flags per-socket. These are the same like SO_XXX.
+ */
+#define SOF_DEBUG (u16_t)0x0001U /* turn on debugging info recording */
+#define SOF_ACCEPTCONN (u16_t)0x0002U /* socket has had listen() */
+#define SOF_REUSEADDR (u16_t)0x0004U /* allow local address reuse */
+#define SOF_KEEPALIVE (u16_t)0x0008U /* keep connections alive */
+#define SOF_DONTROUTE (u16_t)0x0010U /* just use interface addresses */
+#define SOF_BROADCAST (u16_t)0x0020U /* permit sending of broadcast msgs */
+#define SOF_USELOOPBACK (u16_t)0x0040U /* bypass hardware when possible */
+#define SOF_LINGER (u16_t)0x0080U /* linger on close if data present */
+#define SOF_OOBINLINE (u16_t)0x0100U /* leave received OOB data in line */
+#define SOF_REUSEPORT (u16_t)0x0200U /* allow local address & port reuse */
+
+
+
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/bpstruct.h"
+#endif
+PACK_STRUCT_BEGIN
+struct ip_hdr {
+ /* version / header length / type of service */
+ PACK_STRUCT_FIELD(u16_t _v_hl_tos);
+ /* total length */
+ PACK_STRUCT_FIELD(u16_t _len);
+ /* identification */
+ 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 */
+ /* time to live / protocol*/
+ PACK_STRUCT_FIELD(u16_t _ttl_proto);
+ /* checksum */
+ PACK_STRUCT_FIELD(u16_t _chksum);
+ /* source and destination IP addresses */
+ PACK_STRUCT_FIELD(struct ip_addr src);
+ PACK_STRUCT_FIELD(struct ip_addr dest);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/epstruct.h"
+#endif
+
+#define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
+#define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
+#define IPH_TOS(hdr) (htons((ntohs((hdr)->_v_hl_tos) & 0xff)))
+#define IPH_LEN(hdr) ((hdr)->_len)
+#define IPH_ID(hdr) ((hdr)->_id)
+#define IPH_OFFSET(hdr) ((hdr)->_offset)
+#define IPH_TTL(hdr) (ntohs((hdr)->_ttl_proto) >> 8)
+#define IPH_PROTO(hdr) (ntohs((hdr)->_ttl_proto) & 0xff)
+#define IPH_CHKSUM(hdr) ((hdr)->_chksum)
+
+#define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
+#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
+#define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
+#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
+#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((ttl) << 8)))
+#define IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))
+#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
+
+#if IP_DEBUG
+void ip_debug_print(struct pbuf *p);
+#else
+#define ip_debug_print(p)
+#endif /* IP_DEBUG */
+
+#endif /* __LWIP_IP_H__ */
+
+
141 gc/ipv4/lwip/ip_addr.h
@@ -0,0 +1,141 @@
+/*
+ * 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 __LWIP_IP_ADDR_H__
+#define __LWIP_IP_ADDR_H__
+
+#include "lwip/arch.h"
+
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/bpstruct.h"
+#endif
+PACK_STRUCT_BEGIN
+struct ip_addr {
+ PACK_STRUCT_FIELD(u32_t addr);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/epstruct.h"
+#endif
+
+/* For compatibility with BSD code */
+#define HAVE_IN_ADDR
+struct in_addr {
+ u32_t s_addr;
+};
+
+extern const struct ip_addr ip_addr_any;
+extern const struct ip_addr ip_addr_broadcast;
+
+/** IP_ADDR_ can be used as a fixed IP address
+ * for the wildcard and the broadcast address
+ */
+#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
+#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
+
+#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
+#define INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */
+
+/* Definitions of the bits in an Internet address integer.
+
+ On subnets, host and network parts are found according to
+ the subnet mask, not these masks. */
+
+#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000) == 0)
+#define IN_CLASSA_NET 0xff000000
+#define IN_CLASSA_NSHIFT 24
+#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
+#define IN_CLASSA_MAX 128
+
+#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000) == 0x80000000)
+#define IN_CLASSB_NET 0xffff0000
+#define IN_CLASSB_NSHIFT 16
+#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
+#define IN_CLASSB_MAX 65536
+
+#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000) == 0xc0000000)
+#define IN_CLASSC_NET 0xffffff00
+#define IN_CLASSC_NSHIFT 8
+#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
+
+#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000) == 0xe0000000)
+#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
+#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
+#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
+#define IN_MULTICAST(a) IN_CLASSD(a)
+
+#define IN_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000)
+#define IN_BADCLASS(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000)
+
+#define IN_LOOPBACKNET 127 /* official! */
+
+
+#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = htonl(((u32_t)(a & 0xff) << 24) | ((u32_t)(b & 0xff) << 16) | \
+ ((u32_t)(c & 0xff) << 8) | (u32_t)(d & 0xff))
+
+#define ip_addr_set(dest, src) (dest)->addr = \
+ ((src) == NULL? 0:\
+ ((struct ip_addr *)src)->addr)
+#define ip_addr_maskcmp(addr1, addr2, mask) (((addr1)->addr & \
+ (mask)->addr) == \
+ ((addr2)->addr & \
+ (mask)->addr))
+#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
+
+#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
+
+#define ip_addr_isbroadcast(addr1, mask) (((((addr1)->addr) & ~((mask)->addr)) == \
+ (0xffffffff & ~((mask)->addr))) || \
+ ((addr1)->addr == 0xffffffff) || \
+ ((addr1)->addr == 0x00000000))
+
+#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
+
+
+#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%u.%u.%u.%u", \
+ ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \
+ ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \
+ ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \
+ ipaddr?(unsigned int)ntohl((ipaddr)->addr) & 0xff:0U))
+
+/* cast to unsigned int, as it is used as argument to printf functions
+ * which expect integer arguments */
+#define ip4_addr1(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff)
+#define ip4_addr2(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff)
+#define ip4_addr3(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff)
+#define ip4_addr4(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr)) & 0xff)
+#endif /* __LWIP_IP_ADDR_H__ */
+
+
+
+
+
+
46 gc/ipv4/lwip/ip_frag.h
@@ -0,0 +1,46 @@
+/*
+ * 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: Jani Monoses <jani@iv.ro>
+ *
+ */
+
+#ifndef __LWIP_IP_FRAG_H__
+#define __LWIP_IP_FRAG_H__
+
+#include "lwip/err.h"
+#include "lwip/pbuf.h"
+#include "lwip/netif.h"
+#include "lwip/ip_addr.h"
+
+struct pbuf * ip_reass(struct pbuf *);
+err_t ip_frag(struct pbuf *, struct netif *, struct ip_addr *);
+
+#endif /* __LWIP_IP_FRAG_H__ */
+
+
159 gc/lwip/api.h
@@ -0,0 +1,159 @@
+/*
+ * 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 __LWIP_API_H__
+#define __LWIP_API_H__
+
+#include "lwip/opt.h"
+#include "lwip/pbuf.h"
+#include "lwip/sys.h"
+
+#include "lwip/ip.h"
+
+#include "lwip/raw.h"
+#include "lwip/udp.h"
+#include "lwip/tcp.h"
+
+#include "lwip/err.h"
+
+#define NETCONN_NOCOPY 0x00
+#define NETCONN_COPY 0x01
+
+enum netconn_type {
+ NETCONN_TCP,
+ NETCONN_UDP,
+ NETCONN_UDPLITE,
+ NETCONN_UDPNOCHKSUM,
+ NETCONN_RAW
+};
+
+enum netconn_state {
+ NETCONN_NONE,
+ NETCONN_WRITE,
+ NETCONN_ACCEPT,
+ NETCONN_RECV,
+ NETCONN_CONNECT,
+ NETCONN_CLOSE
+};
+
+enum netconn_evt {
+ NETCONN_EVT_RCVPLUS,
+ NETCONN_EVT_RCVMINUS,
+ NETCONN_EVT_SENDPLUS,
+ NETCONN_EVT_SENDMINUS
+};
+
+struct netbuf {
+ struct pbuf *p, *ptr;
+ struct ip_addr *fromaddr;
+ u16_t fromport;
+ err_t err;
+};
+
+struct netconn {
+ enum netconn_type type;
+ enum netconn_state state;
+ union {
+ struct tcp_pcb *tcp;
+ struct udp_pcb *udp;
+ struct raw_pcb *raw;
+ } pcb;
+ err_t err;
+ sys_mbox_t mbox;
+ sys_mbox_t recvmbox;
+ sys_mbox_t acceptmbox;
+ sys_sem_t sem;
+ int socket;
+ u16_t recv_avail;
+ void (* callback)(struct netconn *, enum netconn_evt, u16_t len);
+};
+
+/* Network buffer functions: */
+struct netbuf * netbuf_new (void);
+void netbuf_delete (struct netbuf *buf);
+void * netbuf_alloc (struct netbuf *buf, u16_t size);
+void netbuf_free (struct netbuf *buf);
+void netbuf_ref (struct netbuf *buf,
+ void *dataptr, u16_t size);
+void netbuf_chain (struct netbuf *head,
+ struct netbuf *tail);
+
+u16_t netbuf_len (struct netbuf *buf);
+err_t netbuf_data (struct netbuf *buf,
+ void **dataptr, u16_t *len);
+s8_t netbuf_next (struct netbuf *buf);
+void netbuf_first (struct netbuf *buf);
+
+void netbuf_copy (struct netbuf *buf,
+ void *dataptr, u16_t len);
+void netbuf_copy_partial(struct netbuf *buf, void *dataptr,
+ u16_t len, u16_t offset);
+struct ip_addr * netbuf_fromaddr (struct netbuf *buf);
+u16_t netbuf_fromport (struct netbuf *buf);
+
+/* Network connection functions: */
+struct netconn * netconn_new (enum netconn_type type);
+struct
+netconn *netconn_new_with_callback(enum netconn_type t,
+ void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
+struct
+netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u16_t proto,
+ void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
+err_t netconn_delete (struct netconn *conn);
+enum netconn_type netconn_type (struct netconn *conn);
+err_t netconn_peer (struct netconn *conn,
+ struct ip_addr *addr,
+ u16_t *port);
+err_t netconn_addr (struct netconn *conn,
+ struct ip_addr **addr,
+ u16_t *port);
+err_t netconn_bind (struct netconn *conn,
+ struct ip_addr *addr,
+ u16_t port);
+err_t netconn_connect (struct netconn *conn,
+ struct ip_addr *addr,
+ u16_t port);
+err_t netconn_disconnect (struct netconn *conn);
+err_t netconn_listen (struct netconn *conn);
+struct netconn * netconn_accept (struct netconn *conn);
+struct netbuf * netconn_recv (struct netconn *conn);
+err_t netconn_send (struct netconn *conn,
+ struct netbuf *buf);
+err_t netconn_write (struct netconn *conn,
+ void *dataptr, u16_t size,
+ u8_t copy);
+err_t netconn_close (struct netconn *conn);
+
+err_t netconn_err (struct netconn *conn);
+
+#endif /* __LWIP_API_H__ */
+
+
94 gc/lwip/api_msg.h
@@ -0,0 +1,94 @@
+/*
+ * 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 __LWIP_API_MSG_H__
+#define __LWIP_API_MSG_H__
+
+#include "lwip/opt.h"
+#include "lwip/pbuf.h"
+#include "lwip/sys.h"
+
+#include "lwip/ip.h"
+
+#include "lwip/udp.h"
+#include "lwip/tcp.h"
+
+#include "lwip/api.h"
+
+enum api_msg_type {
+ API_MSG_NEWCONN,
+ API_MSG_DELCONN,
+
+ API_MSG_BIND,
+ API_MSG_CONNECT,
+ API_MSG_DISCONNECT,
+
+ API_MSG_LISTEN,
+ API_MSG_ACCEPT,
+
+ API_MSG_SEND,
+ API_MSG_RECV,
+ API_MSG_WRITE,
+
+ API_MSG_CLOSE,
+
+ API_MSG_MAX
+};
+
+struct api_msg_msg {
+ struct netconn *conn;
+ enum netconn_type conntype;
+ union {
+ struct pbuf *p;
+ struct {
+ struct ip_addr *ipaddr;
+ u16_t port;
+ } bc;
+ struct {
+ void *dataptr;
+ u16_t len;
+ unsigned char copy;
+ } w;
+ sys_mbox_t mbox;
+ u16_t len;
+ } msg;
+};
+
+struct api_msg {
+ enum api_msg_type type;
+ struct api_msg_msg msg;
+};
+
+void api_msg_input(struct api_msg *msg);
+void api_msg_post(struct api_msg *msg);
+
+#endif /* __LWIP_API_MSG_H__ */
+
216 gc/lwip/arch.h
@@ -0,0 +1,216 @@
+/*
+ * 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 __LWIP_ARCH_H__
+#define __LWIP_ARCH_H__
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN 4321
+#endif
+
+#include "arch/cc.h"
+
+#ifndef PACK_STRUCT_BEGIN
+#define PACK_STRUCT_BEGIN
+#endif /* PACK_STRUCT_BEGIN */
+
+#ifndef PACK_STRUCT_END
+#define PACK_STRUCT_END
+#endif /* PACK_STRUCT_END */
+
+#ifndef PACK_STRUCT_FIELD
+#define PACK_STRUCT_FIELD(x) x
+#endif /* PACK_STRUCT_FIELD */
+
+
+
+#ifdef LWIP_PROVIDE_ERRNO
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No child processes */
+#define EAGAIN 11 /* Try again */
+#define ENOMEM 12 /* Out of memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device or resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math argument out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+#define EDEADLK 35 /* Resource deadlock would occur */
+#define ENAMETOOLONG 36 /* File name too long */
+#define ENOLCK 37 /* No record locks available */
+#define ENOSYS 38 /* Function not implemented */
+#define ENOTEMPTY 39 /* Directory not empty */
+#define ELOOP 40 /* Too many symbolic links encountered */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define ENOMSG 42 /* No message of desired type */
+#define EIDRM 43 /* Identifier removed */
+#define ECHRNG 44 /* Channel number out of range */
+#define EL2NSYNC 45 /* Level 2 not synchronized */
+#define EL3HLT 46 /* Level 3 halted */
+#define EL3RST 47 /* Level 3 reset */
+#define ELNRNG 48 /* Link number out of range */
+#define EUNATCH 49 /* Protocol driver not attached */
+#define ENOCSI 50 /* No CSI structure available */
+#define EL2HLT 51 /* Level 2 halted */
+#define EBADE 52 /* Invalid exchange */
+#define EBADR 53 /* Invalid request descriptor */
+#define EXFULL 54 /* Exchange full */
+#define ENOANO 55 /* No anode */
+#define EBADRQC 56 /* Invalid request code */
+#define EBADSLT 57 /* Invalid slot */
+
+#define EDEADLOCK EDEADLK
+
+#define EBFONT 59 /* Bad font file format */
+#define ENOSTR 60 /* Device not a stream */
+#define ENODATA 61 /* No data available */
+#define ETIME 62 /* Timer expired */
+#define ENOSR 63 /* Out of streams resources */
+#define ENONET 64 /* Machine is not on the network */
+#define ENOPKG 65 /* Package not installed */
+#define EREMOTE 66 /* Object is remote */
+#define ENOLINK 67 /* Link has been severed */
+#define EADV 68 /* Advertise error */
+#define ESRMNT 69 /* Srmount error */
+#define ECOMM 70 /* Communication error on send */
+#define EPROTO 71 /* Protocol error */
+#define EMULTIHOP 72 /* Multihop attempted */
+#define EDOTDOT 73 /* RFS specific error */
+#define EBADMSG 74 /* Not a data message */
+#define EOVERFLOW 75 /* Value too large for defined data type */
+#define ENOTUNIQ 76 /* Name not unique on network */
+#define EBADFD 77 /* File descriptor in bad state */
+#define EREMCHG 78 /* Remote address changed */
+#define ELIBACC 79 /* Can not access a needed shared library */
+#define ELIBBAD 80 /* Accessing a corrupted shared library */
+#define ELIBSCN 81 /* .lib section in a.out corrupted */
+#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
+#define ELIBEXEC 83 /* Cannot exec a shared library directly */
+#define EILSEQ 84 /* Illegal byte sequence */
+#define ERESTART 85 /* Interrupted system call should be restarted */
+#define ESTRPIPE 86 /* Streams pipe error */
+#define EUSERS 87 /* Too many users */
+#define ENOTSOCK 88 /* Socket operation on non-socket */
+#define EDESTADDRREQ 89 /* Destination address required */
+#define EMSGSIZE 90 /* Message too long */
+#define EPROTOTYPE 91 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 92 /* Protocol not available */
+#define EPROTONOSUPPORT 93 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
+#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
+#define EPFNOSUPPORT 96 /* Protocol family not supported */
+#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
+#define EADDRINUSE 98 /* Address already in use */
+#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
+#define ENETDOWN 100 /* Network is down */
+#define ENETUNREACH 101 /* Network is unreachable */
+#define ENETRESET 102 /* Network dropped connection because of reset */
+#define ECONNABORTED 103 /* Software caused connection abort */
+#define ECONNRESET 104 /* Connection reset by peer */
+#define ENOBUFS 105 /* No buffer space available */
+#define EISCONN 106 /* Transport endpoint is already connected */
+#define ENOTCONN 107 /* Transport endpoint is not connected */
+#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
+#define ETOOMANYREFS 109 /* Too many references: cannot splice */
+#define ETIMEDOUT 110 /* Connection timed out */
+#define ECONNREFUSED 111 /* Connection refused */
+#define EHOSTDOWN 112 /* Host is down */
+#define EHOSTUNREACH 113 /* No route to host */
+#define EALREADY 114 /* Operation already in progress */
+#define EINPROGRESS 115 /* Operation now in progress */
+#define ESTALE 116 /* Stale NFS file handle */
+#define EUCLEAN 117 /* Structure needs cleaning */
+#define ENOTNAM 118 /* Not a XENIX named type file */
+#define ENAVAIL 119 /* No XENIX semaphores available */
+#define EISNAM 120 /* Is a named type file */
+#define EREMOTEIO 121 /* Remote I/O error */
+#define EDQUOT 122 /* Quota exceeded */
+
+#define ENOMEDIUM 123 /* No medium found */
+#define EMEDIUMTYPE 124 /* Wrong medium type */
+
+
+#define ENSROK 0 /* DNS server returned answer with no data */
+#define ENSRNODATA 160 /* DNS server returned answer with no data */
+#define ENSRFORMERR 161 /* DNS server claims query was misformatted */
+#define ENSRSERVFAIL 162 /* DNS server returned general failure */
+#define ENSRNOTFOUND 163 /* Domain name not found */
+#define ENSRNOTIMP 164 /* DNS server does not implement requested operation */
+#define ENSRREFUSED 165 /* DNS server refused query */
+#define ENSRBADQUERY 166 /* Misformatted DNS query */
+#define ENSRBADNAME 167 /* Misformatted domain name */
+#define ENSRBADFAMILY 168 /* Unsupported address family */
+#define ENSRBADRESP 169 /* Misformatted DNS reply */
+#define ENSRCONNREFUSED 170 /* Could not contact DNS servers */
+#define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */
+#define ENSROF 172 /* End of file */
+#define ENSRFILE 173 /* Error reading file */
+#define ENSRNOMEM 174 /* Out of memory */
+#define ENSRDESTRUCTION 175 /* Application terminated lookup */
+#define ENSRQUERYDOMAINTOOLONG 176 /* Domain name is too long */
+#define ENSRCNAMELOOP 177 /* Domain name is too long */
+
+#ifndef errno
+extern int errno;
+#endif
+
+#endif /* LWIP_PROVIDE_ERRNO */
+
+#endif /* __LWIP_ARCH_H__ */
87 gc/lwip/debug.h
@@ -0,0 +1,87 @@
+/*
+ * 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 __LWIP_DEBUG_H__
+#define __LWIP_DEBUG_H__
+
+#include "arch/cc.h"
+
+/** lower two bits indicate debug level
+ * - 0 off
+ * - 1 warning
+ * - 2 serious
+ * - 3 severe
+ */
+
+#define DBG_LEVEL_OFF 0
+#define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */
+#define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */
+#define DBG_LEVEL_SEVERE 3 /* */
+#define DBG_MASK_LEVEL 3
+
+/** flag for LWIP_DEBUGF to enable that debug message */
+#define DBG_ON 0x80U
+/** flag for LWIP_DEBUGF to disable that debug message */
+#define DBG_OFF 0x00U
+
+/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
+#define DBG_TRACE 0x40U
+/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
+#define DBG_STATE 0x20U
+/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
+#define DBG_FRESH 0x10U
+/** flag for LWIP_DEBUGF to halt after printing this debug message */
+#define DBG_HALT 0x08U
+
+#ifndef LWIP_NOASSERT
+# define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
+#else
+# define LWIP_ASSERT(x,y)
+#endif
+
+#ifdef LWIP_DEBUG
+/** print debug message only if debug message type is enabled...
+ * AND is of correct type AND is at least DBG_LEVEL
+ */
+# define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && (((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
+# define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0)
+#else /* LWIP_DEBUG */
+# define LWIP_DEBUGF(debug,x)
+# define LWIP_ERROR(x)
+#endif /* LWIP_DEBUG */
+
+#endif /* __LWIP_DEBUG_H__ */
+
+
+
+
+
+
47 gc/lwip/def.h
@@ -0,0 +1,47 @@
+/*
+ * 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 __LWIP_DEF_H__
+#define __LWIP_DEF_H__
+
+/* this might define NULL already */
+#include "arch/cc.h"
+
+#define LWIP_MAX(x , y) (x) > (y) ? (x) : (y)
+#define LWIP_MIN(x , y) (x) < (y) ? (x) : (y)
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+
+#endif /* __LWIP_DEF_H__ */
+
212 gc/lwip/dhcp.h
@@ -0,0 +1,212 @@
+/** @file
+ */
+
+#ifndef __LWIP_DHCP_H__
+#define __LWIP_DHCP_H__
+
+#include "lwip/opt.h"
+#include "lwip/netif.h"
+#include "lwip/udp.h"
+
+/** period (in seconds) of the application calling dhcp_coarse_tmr() */
+#define DHCP_COARSE_TIMER_SECS 60
+/** period (in milliseconds) of the application calling dhcp_fine_tmr() */
+#define DHCP_FINE_TIMER_MSECS 500
+
+struct dhcp
+{
+ /** current DHCP state machine state */
+ u8_t state;
+ /** retries of current request */
+ u8_t tries;
+ /** transaction identifier of last sent request */
+ u32_t xid;
+ /** our connection to the DHCP server */
+ struct udp_pcb *pcb;
+ /** (first) pbuf of incoming msg */
+ struct pbuf *p;
+ /** incoming msg */
+ struct dhcp_msg *msg_in;
+ /** incoming msg options */
+ struct dhcp_msg *options_in;
+ /** ingoing msg options length */
+ u16_t options_in_len;
+
+ struct pbuf *p_out; /* pbuf of outcoming msg */
+ struct dhcp_msg *msg_out; /* outgoing msg */
+ u16_t options_out_len; /* outgoing msg options length */
+ u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
+ u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
+ u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
+ struct ip_addr server_ip_addr; /* dhcp server address that offered this lease */
+ struct ip_addr offered_ip_addr;
+ struct ip_addr offered_sn_mask;
+ struct ip_addr offered_gw_addr;
+ struct ip_addr offered_bc_addr;
+ u32_t offered_t0_lease; /* lease period (in seconds) */
+ u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
+ u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */
+/** Patch #1308
+ * TODO: See dhcp.c "TODO"s
+ */
+#if 0
+ struct ip_addr offered_si_addr;
+ u8_t *boot_file_name;
+#endif
+};
+
+/* MUST be compiled with "pack structs" or equivalent! */
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/bpstruct.h"
+#endif
+PACK_STRUCT_BEGIN
+/** minimum set of fields of any DHCP message */
+struct dhcp_msg
+{
+ PACK_STRUCT_FIELD(u8_t op);
+ PACK_STRUCT_FIELD(u8_t htype);
+ PACK_STRUCT_FIELD(u8_t hlen);
+ PACK_STRUCT_FIELD(u8_t hops);
+ PACK_STRUCT_FIELD(u32_t xid);
+ PACK_STRUCT_FIELD(u16_t secs);
+ PACK_STRUCT_FIELD(u16_t flags);
+ PACK_STRUCT_FIELD(u32_t ciaddr);
+ PACK_STRUCT_FIELD(u32_t yiaddr);
+ PACK_STRUCT_FIELD(u32_t siaddr);
+ PACK_STRUCT_FIELD(u32_t giaddr);
+#define DHCP_CHADDR_LEN 16U
+ PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
+#define DHCP_SNAME_LEN 64U
+ PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
+#define DHCP_FILE_LEN 128U
+ PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
+ PACK_STRUCT_FIELD(u32_t cookie);
+#define DHCP_MIN_OPTIONS_LEN 68U
+/** allow this to be configured in lwipopts.h, but not too small */
+#if ((!defined(DHCP_OPTIONS_LEN)) || (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
+/** set this to be sufficient for your options in outgoing DHCP msgs */
+# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
+#endif
+ PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+#ifdef PACK_STRUCT_USE_INCLUDES
+# include "arch/epstruct.h"
+#endif
+
+/** start DHCP configuration */
+err_t dhcp_start(struct netif *netif);
+/** stop DHCP configuration */
+void dhcp_stop(struct netif *netif);
+/** enforce lease renewal */
+err_t dhcp_renew(struct netif *netif);
+/** inform server of our IP address */
+void dhcp_inform(struct netif *netif);
+
+/** if enabled, check whether the offered IP address is not in use, using ARP */
+#if DHCP_DOES_ARP_CHECK
+void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr);
+#endif
+
+/** to be called every minute */
+void dhcp_coarse_tmr(void);
+/** to be called every half second */
+void dhcp_fine_tmr(void);
+
+/** DHCP message item offsets and length */
+#define DHCP_MSG_OFS (UDP_DATA_OFS)
+ #define DHCP_OP_OFS (DHCP_MSG_OFS + 0)
+ #define DHCP_HTYPE_OFS (DHCP_MSG_OFS + 1)
+ #define DHCP_HLEN_OFS (DHCP_MSG_OFS + 2)
+ #define DHCP_HOPS_OFS (DHCP_MSG_OFS + 3)
+ #define DHCP_XID_OFS (DHCP_MSG_OFS + 4)
+ #define DHCP_SECS_OFS (DHCP_MSG_OFS + 8)
+ #define DHCP_FLAGS_OFS (DHCP_MSG_OFS + 10)
+ #define DHCP_CIADDR_OFS (DHCP_MSG_OFS + 12)
+ #define DHCP_YIADDR_OFS (DHCP_MSG_OFS + 16)
+ #define DHCP_SIADDR_OFS (DHCP_MSG_OFS + 20)
+ #define DHCP_GIADDR_OFS (DHCP_MSG_OFS + 24)
+ #define DHCP_CHADDR_OFS (DHCP_MSG_OFS + 28)
+ #define DHCP_SNAME_OFS (DHCP_MSG_OFS + 44)
+ #define DHCP_FILE_OFS (DHCP_MSG_OFS + 108)
+#define DHCP_MSG_LEN 236
+
+#define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN)
+#define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
+
+#define DHCP_CLIENT_PORT 68
+#define DHCP_SERVER_PORT 67
+
+/** DHCP client states */
+#define DHCP_REQUESTING 1
+#define DHCP_INIT 2
+#define DHCP_REBOOTING 3
+#define DHCP_REBINDING 4
+#define DHCP_RENEWING 5
+#define DHCP_SELECTING 6
+#define DHCP_INFORMING 7
+#define DHCP_CHECKING 8
+#define DHCP_PERMANENT 9
+#define DHCP_BOUND 10
+/** not yet implemented #define DHCP_RELEASING 11 */
+#define DHCP_BACKING_OFF 12
+#define DHCP_OFF 13
+
+#define DHCP_BOOTREQUEST 1
+#define DHCP_BOOTREPLY 2
+
+#define DHCP_DISCOVER 1
+#define DHCP_OFFER 2
+#define DHCP_REQUEST 3
+#define DHCP_DECLINE 4
+#define DHCP_ACK 5
+#define DHCP_NAK 6
+#define DHCP_RELEASE 7
+#define DHCP_INFORM 8
+
+#define DHCP_HTYPE_ETH 1
+
+#define DHCP_HLEN_ETH 6
+
+#define DHCP_BROADCAST_FLAG 15
+#define DHCP_BROADCAST_MASK (1 << DHCP_FLAG_BROADCAST)
+
+/** BootP options */
+#define DHCP_OPTION_PAD 0
+#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */
+#define DHCP_OPTION_ROUTER 3
+#define DHCP_OPTION_HOSTNAME 12
+#define DHCP_OPTION_IP_TTL 23
+#define DHCP_OPTION_MTU 26
+#define DHCP_OPTION_BROADCAST 28
+#define DHCP_OPTION_TCP_TTL 37
+#define DHCP_OPTION_END 255
+
+/** DHCP options */
+#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
+#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
+#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */
+
+#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */
+#define DHCP_OPTION_MESSAGE_TYPE_LEN 1
+
+
+#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */
+#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */
+
+#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */
+#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
+
+#define DHCP_OPTION_T1 58 /* T1 renewal time */
+#define DHCP_OPTION_T2 59 /* T2 rebinding time */
+#define DHCP_OPTION_CLIENT_ID 61
+#define DHCP_OPTION_TFTP_SERVERNAME 66
+#define DHCP_OPTION_BOOTFILE 67
+
+/** possible combinations of overloading the file and sname fields with options */
+#define DHCP_OVERLOAD_NONE 0
+#define DHCP_OVERLOAD_FILE 1
+#define DHCP_OVERLOAD_SNAME 2
+#define DHCP_OVERLOAD_SNAME_FILE 3
+
+#endif /*__LWIP_DHCP_H__*/
70 gc/lwip/err.h
@@ -0,0 +1,70 @@
+/*
+ * 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 __LWIP_ERR_H__
+#define __LWIP_ERR_H__
+
+#include "lwip/opt.h"
+
+#include "arch/cc.h"
+
+typedef s8_t err_t;
+
+/* Definitions for error constants. */
+
+#define ERR_OK 0 /* No error, everything OK. */
+#define ERR_MEM -1 /* Out of memory error. */
+#define ERR_BUF -2 /* Buffer error. */
+
+
+#define ERR_ABRT -3 /* Connection aborted. */
+#define ERR_RST -4 /* Connection reset. */
+#define ERR_CLSD -5 /* Connection closed. */
+#define ERR_CONN -6 /* Not connected. */
+
+#define ERR_VAL -7 /* Illegal value. */
+
+#define ERR_ARG -8 /* Illegal argument. */
+
+#define ERR_RTE -9 /* Routing problem. */
+
+#define ERR_USE -10 /* Address in use. */
+
+#define ERR_IF -11 /* Low-level netif error */
+#define ERR_ISCONN -12 /* Already connected. */
+
+
+#ifdef LWIP_DEBUG
+extern char *lwip_strerr(err_t err);
+#else
+#define lwip_strerr(x) ""
+#endif /* LWIP_DEBUG */
+#endif /* __LWIP_ERR_H__ */
221 gc/lwip/lwipopts.h
@@ -0,0 +1,221 @@
+/*
+ * 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 __LWIPOPTS_H__
+#define __LWIPOPTS_H__
+
+#include <string.h>
+
+#define NO_SYS 1
+#define LWIP_CALLBACK_API 1
+#undef LWIP_EVENT_API
+#define TCPIP_THREAD_PRIO 125
+#define SYS_LIGHTWEIGHT_PROT 1
+
+/* ---------- Memory options ---------- */
+/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
+ lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
+ byte alignment -> define MEM_ALIGNMENT to 2. */
+#define MEM_ALIGNMENT 4
+
+/* MEM_SIZE: the size of the heap memory. If the application will send
+a lot of data that needs to be copied, this should be set high. */
+#define MEM_SIZE 128*1024
+
+/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
+ sends a lot of data out of ROM (or other static memory), this
+ should be set high. */
+#define MEMP_NUM_PBUF 256
+/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+ per active UDP "connection". */
+#define MEMP_NUM_UDP_PCB 4
+/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
+ connections. */
+#define MEMP_NUM_TCP_PCB 16
+/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
+ connections. */
+#define MEMP_NUM_TCP_PCB_LISTEN 16
+/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
+ segments. */
+#define MEMP_NUM_TCP_SEG 64
+
+/* The following four are used only with the sequential API and can be
+ set to 0 if the application only will use the raw API. */
+/* MEMP_NUM_NETBUF: the number of struct netbufs. */
+#define MEMP_NUM_NETBUF 0
+/* MEMP_NUM_NETCONN: the number of struct netconns. */
+#define MEMP_NUM_NETCONN 0
+/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
+ communication between the TCP/IP stack and the sequential
+ programs. */
+#define MEMP_NUM_API_MSG 0
+/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
+ for sequential API communication and incoming packets. Used in
+ src/api/tcpip.c. */
+#define MEMP_NUM_TCPIP_MSG 0
+/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
+ timeouts. */
+#define MEMP_NUM_SYS_TIMEOUT 0
+
+/* ---------- Pbuf options ---------- */
+/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+#define PBUF_POOL_SIZE 256
+
+/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
+#define PBUF_POOL_BUFSIZE 2048
+
+/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+ link level header. */
+#define PBUF_LINK_HLEN 16
+
+/* ---------- TCP options ---------- */
+#define LWIP_TCP 1
+#define TCP_TTL 255
+
+/* Controls if TCP should queue segments that arrive out of
+ order. Define to 0 if your device is low on memory. */
+#define TCP_QUEUE_OOSEQ 1
+
+/* TCP Maximum segment size. */
+#define TCP_MSS 1476
+
+/* TCP sender buffer space (bytes). */
+#define TCP_SND_BUF 32*1024
+
+/* TCP sender buffer space (pbufs). This must be at least = 2 *
+ TCP_SND_BUF/TCP_MSS for things to work. */
+#define TCP_SND_QUEUELEN 2 * TCP_SND_BUF/TCP_MSS
+
+/* TCP receive window. */
+#define TCP_WND 16*1024
+
+/* Maximum number of retransmissions of data segments. */
+#define TCP_MAXRTX 12
+
+/* Maximum number of retransmissions of SYN segments. */
+#define TCP_SYNMAXRTX 4
+
+/* ---------- ARP options ---------- */
+#define ARP_TABLE_SIZE 10
+#define ARP_QUEUEING 0
+/**
+ * - If enabled, cache entries are generated for every kind of ARP traffic or
+ * broadcast IP traffic. This enhances behaviour for sending to a dynamic set
+ * of hosts, for example if acting as a gateway.
+ * - If disabled, cache entries are generated only for IP destination addresses
+ * in use by lwIP or applications. This enhances performance if sending to a small,
+ * reasonably static number of hosts. Typically for embedded devices.
+ */
+#define ETHARP_ALWAYS_INSERT 0
+
+/* ---------- IP options ---------- */
+/* Define IP_FORWARD to 1 if you wish to have the ability to forward
+ IP packets across network interfaces. If you are going to run lwIP
+ on a device with only one network interface, define this to 0. */
+#define IP_FORWARD 0
+
+/* If defined to 1, IP options are allowed (but not parsed). If
+ defined to 0, all packets with IP options are dropped. */
+#define IP_OPTIONS 1
+
+/* ---------- ICMP options ---------- */
+#define ICMP_TTL 255
+
+
+/* ---------- DHCP options ---------- */
+/* Define LWIP_DHCP to 1 if you want DHCP configuration of
+ interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
+ turning this on does currently not work. */
+#define LWIP_DHCP 1
+
+/* 1 if you want to do an ARP check on the offered address
+ (recommended). */
+#define DHCP_DOES_ARP_CHECK 1
+
+/* ---------- UDP options ---------- */
+#define LWIP_UDP 1
+#define UDP_TTL 255
+
+
+/* ---------- Statistics options ---------- */
+/*#define STATS*/
+
+#ifdef STATS
+#define LINK_STATS
+#define IP_STATS
+#define ICMP_STATS
+#define UDP_STATS
+#define TCP_STATS
+#define MEM_STATS
+#define MEMP_STATS
+#define PBUF_STATS
+#define SYS_STATS
+#endif /* STATS */
+#define BYTE_ORDER BIG_ENDIAN
+
+#if 0
+#define DBG_TYPES_ON -1
+#define DEMO_DEBUG DBG_OFF
+#define ETHARP_DEBUG DBG_OFF
+#define NETIF_DEBUG DBG_OFF
+#define PBUF_DEBUG DBG_OFF
+#define API_LIB_DEBUG DBG_OFF
+#define API_MSG_DEBUG DBG_OFF
+#define SOCKETS_DEBUG DBG_OFF
+#define ICMP_DEBUG DBG_OFF
+#define INET_DEBUG DBG_OFF
+#define IP_DEBUG DBG_OFF
+#define IP_REASS_DEBUG DBG_OFF
+#define MEM_DEBUG DBG_OFF
+#define MEMP_DEBUG DBG_OFF
+#define SYS_DEBUG DBG_OFF
+#define RAW_DEBUG DBG_OFF
+#define TCP_DEBUG DBG_OFF
+#define TCP_INPUT_DEBUG DBG_ON
+#define TCP_FR_DEBUG DBG_OFF
+#define TCP_RTO_DEBUG DBG_OFF
+#define TCP_REXMIT_DEBUG DBG_OFF
+#define TCP_CWND_DEBUG DBG_OFF
+#define TCP_WND_DEBUG DBG_OFF
+#define TCP_OUTPUT_DEBUG DBG_ON
+#define TCP_RST_DEBUG DBG_OFF
+#define TCP_QLEN_DEBUG DBG_OFF
+#define UDP_DEBUG DBG_OFF
+#define TCPIP_DEBUG DBG_OFF
+#define PPP_DEBUG DBG_OFF
+#define SLIP_DEBUG DBG_OFF
+#define DHCP_DEBUG DBG_OFF
+
+#define DBG_MIN_LEVEL DBG_LEVEL_OFF
+#endif
+
+
+#endif /* __LWIPOPTS_H__ */
61 gc/lwip/mem.h
@@ -0,0 +1,61 @@
+/*
+ * 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 __LWIP_MEM_H__
+#define __LWIP_MEM_H__
+
+#include "lwip/opt.h"
+#include "lwip/arch.h"
+
+#if MEM_SIZE > 64000l
+typedef u32_t mem_size_t;
+#else
+typedef u16_t mem_size_t;
+#endif /* MEM_SIZE > 64000 */
+
+
+void mem_init(void);
+
+void *mem_malloc(mem_size_t size);
+void mem_free(void *mem);
+void *mem_realloc(void *mem, mem_size_t size);
+void *mem_reallocm(void *mem, mem_size_t size);
+
+#ifndef MEM_ALIGN_SIZE
+#define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
+#endif