Project import
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1e6129b --- /dev/null +++ b/Makefile
@@ -0,0 +1,214 @@ +# +# Copyright (c) 2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file is the make file for LwIP, a Lightweight IPv4- +# and IPv6 TCP/IP stack. +# + +BuildConfigSpecialized := Yes +BuildProductSpecialized := Yes + +include pre.mak + +ifeq ($(BUILD_FEATURE_LWIP),1) + +PackageRoot := . + +PackageName := lwip + +PackageSourceDir := $(LwipSrcPath)/$(PackageName) + +GeneratePackagePaths = $(addprefix $(call Slashify,$(PackageSourceDir)),$(1)) + +LicenseSourceFile := $(PackageSourceDir)/COPYING + +# Turn off warnings for missing protos +CCFLAGS += $(call ToolDeassertWarningFlag,$(WarnMissingProtos)) + +all: $(PackageDefaultGoal) + +# Generate the package license contents. + +$(LicenseSourceFile): source + +$(PackageLicenseFile): $(LicenseSourceFile) + $(copy-result) + +# We are building this package from version-controlled source, so +# there is nothing to do for this target goal. + +$(PackageSourceDir): + +# Prepare the sources. + +.PHONY: source +source: | $(PackageSourceDir) + +# Patch the sources, if necessary. + +.PHONY: patch +patch: source + +# Configure the source for building. + +.PHONY: configure +configure: source + +# Build the source. + +.PHONY: build +build: configure + +.PHONY: stage stage-headers +stage: build | $(ResultDirectory) +stage: stage-headers + +lwip_API_PATHS = src/api/api_lib.c \ + src/api/api_msg.c \ + src/api/err.c \ + src/api/netbuf.c \ + src/api/netdb.c \ + src/api/netifapi.c \ + src/api/sockets.c \ + src/api/tcpip.c + +lwip_CORE_PATHS = src/core/def.c \ + src/core/dhcp.c \ + src/core/dns.c \ + src/core/inet_chksum.c \ + src/core/init.c \ + src/core/ipv4/autoip.c \ + src/core/ipv4/icmp.c \ + src/core/ipv4/igmp.c \ + src/core/ipv4/ip4.c \ + src/core/ipv4/ip4_addr.c \ + src/core/ipv4/ip_frag.c \ + src/core/ipv6/dhcp6.c \ + src/core/ipv6/ethip6.c \ + src/core/ipv6/icmp6.c \ + src/core/ipv6/inet6.c \ + src/core/ipv6/ip6.c \ + src/core/ipv6/ip6_addr.c \ + src/core/ipv6/ip6_frag.c \ + src/core/ipv6/ip6_route_table.c \ + src/core/ipv6/mld6.c \ + src/core/ipv6/nd6.c \ + src/core/mem.c \ + src/core/memp.c \ + src/core/netif.c \ + src/core/pbuf.c \ + src/core/raw.c \ + src/core/stats.c \ + src/core/sys.c \ + src/core/tcp.c \ + src/core/tcp_in.c \ + src/core/tcp_out.c \ + src/core/timers.c \ + src/core/udp.c + +lwip_NETIF_PATHS = src/netif/etharp.c + +lwip_SOURCE_PATHS = $(lwip_API_PATHS) \ + $(lwip_CORE_PATHS) \ + $(lwip_NETIF_PATHS) + +lwip_INCLUDE_DIRS = src/include \ + src/include/ipv4 \ + src/include/ipv6 + +lwip_INCLUDE_PATHS = $(call GeneratePackagePaths,$(lwip_INCLUDE_DIRS)) + +lwip_PACKAGE_SOURCE_PATHS = $(call GeneratePackagePaths,$(lwip_SOURCE_PATHS)) + +# Tell make where to search for the sources, cleaning up the leading +# ./ strictly for cosmetic display purposes in the process. + +VPATH = $(subst ./,,$(dir $(lwip_PACKAGE_SOURCE_PATHS))) + + +ARCHIVES = lwip + +lwip_SOURCES = $(notdir $(lwip_PACKAGE_SOURCE_PATHS)) + +ifdef BUILD_FEATURE_WEAVE_TEST +lwip_INCLUDES = $(lwip_INCLUDE_PATHS) \ + os/freertos \ + $(NlERIncludePaths) \ + products \ + products/$(BuildProduct) +else +lwip_INCLUDES = $(lwip_INCLUDE_PATHS) \ + os/$(TargetOS) \ + $(NlERIncludePaths) \ + products \ + products/$(BuildProduct) +endif + +lwip_CPPFLAGS = -Wno-error=implicit-function-declaration \ + -Wno-error=strict-prototypes \ + +-include ./products/$(BuildProduct)/lwip.mak + +LwIPHeaderSourcePaths = $(wildcard $(addsuffix /*/*.h,$(lwip_INCLUDE_PATHS))) +LwIPHeaderSourceStems = $(subst $(PackageSourceDir)/src/include,,$(LwIPHeaderSourcePaths)) +LwIPHeaderSourcePattern = $(call GeneratePackagePaths,src/include/%) +LwIPHeaderResultPaths = $(call GenerateResultPaths,,$(LwIPHeaderSourceStems)) +LwIPHeaderResultPattern = $(call GenerateResultPaths,,%) + +LwIPOptionHeaderName = lwipopts.h +LwIPPoolHeaderName = lwippools.h +LwIPOptionHeaderStems = $(LwIPOptionHeaderName) $(LwIPPoolHeaderName) common/$(LwIPOptionHeaderName) $(BuildProduct)/$(LwIPOptionHeaderName) +LwIPOptionHeaderSourceDirectory = products +LwIPOptionHeaderSourcePaths = $(addprefix $(call Slashify,$(LwIPOptionHeaderSourceDirectory)),$(LwIPOptionHeaderStems)) +LwIPOptionHeaderResultDirectory = $(ResultDirectory) +LwIPOptionHeaderResultPaths = $(call GenerateResultPaths,,$(LwIPOptionHeaderStems)) + +LwIPArchHeaderNames = cc.h perf.h sys_arch.h +ifdef BUILD_FEATURE_WEAVE_TEST +LwIPArchHeaderSourcePaths = $(addprefix os/freertos/arch/,$(LwIPArchHeaderNames)) +LwIPArchHeaderSourceStems = $(subst os/freertos/,,$(LwIPArchHeaderSourcePaths)) +LwIPArchHeaderSourcePattern = os/freertos/% +else +LwIPArchHeaderSourcePaths = $(addprefix os/$(TargetOS)/arch/,$(LwIPArchHeaderNames)) +LwIPArchHeaderSourceStems = $(subst os/$(TargetOS)/,,$(LwIPArchHeaderSourcePaths)) +LwIPArchHeaderSourcePattern = os/$(TargetOS)/% +endif +LwIPArchHeaderResultPaths = $(call GenerateResultPaths,,$(LwIPArchHeaderSourceStems)) +LwIPArchHeaderResultPattern = $(call GenerateResultPaths,,%) + +ResultPaths += $(LwIPHeaderResultPaths) \ + $(LwIPOptionHeaderResultPaths) \ + $(LwIPArchHeaderResultPaths) + +stage-headers: $(LwIPHeaderResultPaths) $(LwIPOptionHeaderResultPaths) $(LwIPArchHeaderResultPaths) + +prepare: stage-headers + +$(LwIPHeaderResultPaths): $(LwIPHeaderResultPattern): $(LwIPHeaderSourcePattern) + $(install-result) + +$(LwIPOptionHeaderResultPaths): $(LwIPOptionHeaderResultDirectory)/%: $(LwIPOptionHeaderSourceDirectory)/% | $(LwIPOptionHeaderResultDirectory) + $(install-result) + +$(LwIPArchHeaderResultPaths): $(LwIPArchHeaderResultPattern): $(LwIPArchHeaderSourcePattern) + $(install-result) + +endif #ifeq ($(BUILD_FEATURE_LWIP),1) + +# While the LwIP library uses the nlbuild build system because it has no +# make- compatible build system of its own, it is still third-party +# software and we do not want to enforce style semantics on it. +# Consequently, set PrettyPaths to empty. + +PrettyPaths := $(NULL) + +include post.mak
diff --git a/lwip.url b/lwip.url new file mode 100644 index 0000000..979c7ee --- /dev/null +++ b/lwip.url
@@ -0,0 +1 @@ +git://git.sv.gnu.org/lwip.git
diff --git a/lwip.version b/lwip.version new file mode 100644 index 0000000..4ea59fb --- /dev/null +++ b/lwip.version
@@ -0,0 +1 @@ +a4a41b9023ef5b3a7c4a1cd82fb167fc63e706df
diff --git a/os/darwin/arch/cc.h b/os/darwin/arch/cc.h new file mode 100644 index 0000000..3a80e53 --- /dev/null +++ b/os/darwin/arch/cc.h
@@ -0,0 +1,85 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture- and toolchain- + * specific constants and types required for building + * LwIP against DARWIN. + * + */ + +#ifndef NL_LWIP_DARWIN_ARCH_CC_H +#define NL_LWIP_DARWIN_ARCH_CC_H + +#include <errno.h> +#include <stdlib.h> +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> + +#include <sys/time.h> +#include <sys/types.h> + +typedef int8_t s8_t; +typedef uint8_t u8_t; +typedef int16_t s16_t; +typedef uint16_t u16_t; +typedef int32_t s32_t; +typedef uint32_t u32_t; + +typedef ptrdiff_t mem_ptr_t; + +typedef u32_t sys_prot_t; + +#ifndef LWIP_NOASSERT +#define LWIP_PLATFORM_ASSERT(message) do { puts(message); } while (0) +#else +#define LWIP_PLATFORM_ASSERT(message) +#endif + +/* Darwin defines BYTE_ORDER to definitions that should be identical + * to those LwIP has defined for LITTLE_ENDIAN and BIG_ENDIAN. Ensure + * that's the case. + */ +#if !defined(BYTE_ORDER) +# if defined(__LITTLE_ENDIAN__) +# define BYTE_ORDER LITTLE_ENDIAN +# elif defined(__BIG_ENDIAN__) +# define BYTE_ORDER BIG_ENDIAN +# endif +#else +# if defined(__LITTLE_ENDIAN__) && (BYTE_ORDER != LITTLE_ENDIAN) +# error "Darwin's BYTE_ORDER is inconsistent with LwIP's LITTLE_ENDIAN." +# elif defined(__BIG_ENDIAN__) && (BYTE_ORDER != BIG_ENDIAN) +# error "Darwin's BYTE_ORDER is inconsistent with LwIP's BIG_ENDIAN." +# endif +#endif + +/* LwIP Debug Output Formatting and Function Calls */ + +#define U16_F "hu" +#define S16_F "hd" +#define X16_F "hx" +#define U32_F "u" +#define S32_F "d" +#define X32_F "x" +#define SZT_F "zu" + +#define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) +#define PACK_STRUCT_FIELD(x) x + +#define LWIP_PLATFORM_DIAG(x) \ + do { \ + printf x; \ + } while (0) + +#endif /* NL_LWIP_DARWIN_ARCH_CC_H */
diff --git a/os/darwin/arch/perf.h b/os/darwin/arch/perf.h new file mode 100644 index 0000000..9d6011d --- /dev/null +++ b/os/darwin/arch/perf.h
@@ -0,0 +1,26 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture-specific constants, + * interfaces and types required for LwIP performance + * measurement. + * + */ + +#ifndef NL_LWIP_DARWIN_ARCH_PERF_H +#define NL_LWIP_DARWIN_ARCH_PERF_H + +#define PERF_START +#define PERF_STOP(s) + +#endif /* NL_LWIP_DARWIN_ARCH_PERF_H */
diff --git a/os/darwin/arch/sys_arch.h b/os/darwin/arch/sys_arch.h new file mode 100644 index 0000000..c268a5b --- /dev/null +++ b/os/darwin/arch/sys_arch.h
@@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture- and operating + * system- specific constants and types required for building + * LwIP against DARWIN. + * + */ + +#ifndef NL_LWIP_DARWIN_ARCH_SYS_ARCH_H +#define NL_LWIP_DARWIN_ARCH_SYS_ARCH_H + +/* Preprocessor Macros */ + +#define SYS_MBOX_NULL NULL +#define SYS_SEM_NULL NULL + +/* Forward Declarations */ + +struct sys_mbox; +struct sys_sem; +struct sys_thread; + +/* Type Definitions */ + +typedef struct sys_mbox *sys_mbox_t; +typedef struct sys_sem *sys_sem_t; +typedef struct sys_thread *sys_thread_t; + + +#endif /* NL_LWIP_DARWIN_ARCH_SYS_ARCH_H */
diff --git a/os/freertos/arch/cc.h b/os/freertos/arch/cc.h new file mode 100644 index 0000000..4c78b15 --- /dev/null +++ b/os/freertos/arch/cc.h
@@ -0,0 +1,76 @@ +/* + * + * Copyright (c) 2012 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture- and toolchain- + * specific constants and types required for building + * LwIP against FreeRTOS. + * + */ + +#ifndef NL_LWIP_FREERTOS_ARCH_CC_H +#define NL_LWIP_FREERTOS_ARCH_CC_H + +#include <errno.h> +#include <malloc.h> +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> + +#include <sys/time.h> + +typedef int8_t s8_t; +typedef uint8_t u8_t; +typedef int16_t s16_t; +typedef uint16_t u16_t; +typedef int32_t s32_t; +typedef uint32_t u32_t; + +typedef ptrdiff_t mem_ptr_t; + +typedef int sys_prot_t; + +#ifndef LWIP_NOASSERT +#define LWIP_PLATFORM_ASSERT(message) do { puts(message); } while (0) +#else +#define LWIP_PLATFORM_ASSERT(message) +#endif + +#ifndef BYTE_ORDER +#if defined(__LITTLE_ENDIAN__) +#define BYTE_ORDER LITTLE_ENDIAN +#elif defined(__BIG_ENDIAN__) +#define BYTE_ORDER BIG_ENDIAN +#elif defined(__BYTE_ORDER__) +#define BYTE_ORDER __BYTE_ORDER__ +#endif +#endif + +/* LwIP Debug Output Formatting and Function Calls */ + +#define U16_F "u" +#define S16_F "d" +#define X16_F "x" +#define U32_F "lu" +#define S32_F "ld" +#define X32_F "lx" +#define SZT_F "u" + +#define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) +#define PACK_STRUCT_FIELD(x) x + +#define LWIP_PLATFORM_DIAG(x) \ + do { \ + printf x; \ + } while (0) + +#endif /* NL_LWIP_FREERTOS_ARCH_CC_H */
diff --git a/os/freertos/arch/perf.h b/os/freertos/arch/perf.h new file mode 100644 index 0000000..e781d1e --- /dev/null +++ b/os/freertos/arch/perf.h
@@ -0,0 +1,31 @@ +/* + * + * Copyright (c) 2012 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture-specific constants, + * interfaces and types required for LwIP performance + * measurement. + * + */ + +#ifndef NL_LWIP_FREERTOS_ARCH_PERF_H +#define NL_LWIP_FREERTOS_ARCH_PERF_H + +#define PERF_START +#define PERF_STOP(s) + +#define sys_profile_interval_set_pbuf_highwatermark(x,y) +#define sys_profile_pbuf_allocate(pbuf) +#define sys_profile_pbuf_free(pbuf) +#define sys_profile_pbuf_transfer(x, y) + +#endif /* NL_LWIP_FREERTOS_ARCH_PERF_H */
diff --git a/os/freertos/arch/sys_arch.h b/os/freertos/arch/sys_arch.h new file mode 100644 index 0000000..8b5b3f8 --- /dev/null +++ b/os/freertos/arch/sys_arch.h
@@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2012 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture- and operating + * system- specific constants and types required for building + * LwIP against FreeRTOS. + * + */ + +#ifndef NL_LWIP_FREERTOS_ARCH_SYS_ARCH_H +#define NL_LWIP_FREERTOS_ARCH_SYS_ARCH_H + +#include "FreeRTOS.h" +#include "queue.h" +#include "semphr.h" +#include "task.h" + +typedef xQueueHandle sys_mbox_t; +typedef xSemaphoreHandle sys_mutex_t; +typedef xSemaphoreHandle sys_sem_t; +typedef xTaskHandle sys_thread_t; + +#endif /* NL_LWIP_FREERTOS_ARCH_SYS_ARCH_H */
diff --git a/os/linux/arch/cc.h b/os/linux/arch/cc.h new file mode 100644 index 0000000..562b386 --- /dev/null +++ b/os/linux/arch/cc.h
@@ -0,0 +1,76 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture- and toolchain- + * specific constants and types required for building + * LwIP against Linux. + * + */ + +#ifndef NL_LWIP_LINUX_ARCH_CC_H +#define NL_LWIP_LINUX_ARCH_CC_H + +#include <errno.h> +#include <malloc.h> +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> + +#include <sys/time.h> + +typedef int8_t s8_t; +typedef uint8_t u8_t; +typedef int16_t s16_t; +typedef uint16_t u16_t; +typedef int32_t s32_t; +typedef uint32_t u32_t; + +typedef ptrdiff_t mem_ptr_t; + +typedef u32_t sys_prot_t; + +#ifndef LWIP_NOASSERT +#define LWIP_PLATFORM_ASSERT(message) do { puts(message); } while (0) +#else +#define LWIP_PLATFORM_ASSERT(message) +#endif + +#ifndef BYTE_ORDER +#if defined(__LITTLE_ENDIAN__) || defined(__ORDER_LITTLE_ENDIAN__) +#define BYTE_ORDER LITTLE_ENDIAN +#elif defined(__BIG_ENDIAN__) || defined (__ORDER_BIG_ENDIAN__) +#define BYTE_ORDER BIG_ENDIAN +#elif defined(__BYTE_ORDER__) +#define BYTE_ORDER __BYTE_ORDER__ +#endif +#endif + +/* LwIP Debug Output Formatting and Function Calls */ + +#define U16_F "hu" +#define S16_F "hd" +#define X16_F "hx" +#define U32_F "u" +#define S32_F "d" +#define X32_F "x" +#define SZT_F "zu" + +#define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) +#define PACK_STRUCT_FIELD(x) x + +#define LWIP_PLATFORM_DIAG(x) \ + do { \ + printf x; \ + } while (0) + +#endif /* NL_LWIP_LINUX_ARCH_CC_H */
diff --git a/os/linux/arch/perf.h b/os/linux/arch/perf.h new file mode 100644 index 0000000..606bf64 --- /dev/null +++ b/os/linux/arch/perf.h
@@ -0,0 +1,28 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture-specific constants, + * interfaces and types required for LwIP performance + * measurement. + * + */ + +#ifndef NL_LWIP_LINUX_ARCH_PERF_H +#define NL_LWIP_LINUX_ARCH_PERF_H + +#define PERF_START +#define PERF_STOP(s) + +#define sys_profile_interval_set_pbuf_highwatermark(x,y) + +#endif /* NL_LWIP_LINUX_ARCH_PERF_H */
diff --git a/os/linux/arch/sys_arch.h b/os/linux/arch/sys_arch.h new file mode 100644 index 0000000..fe27495 --- /dev/null +++ b/os/linux/arch/sys_arch.h
@@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines processor-architecture- and operating + * system- specific constants and types required for building + * LwIP against Linux. + * + */ + +#ifndef NL_LWIP_LINUX_ARCH_SYS_ARCH_H +#define NL_LWIP_LINUX_ARCH_SYS_ARCH_H + +/* Preprocessor Macros */ + +#define SYS_MBOX_NULL NULL +#define SYS_SEM_NULL NULL + +/* Forward Declarations */ + +struct sys_mbox; +struct sys_sem; +struct sys_thread; + +/* Type Definitions */ + +typedef struct sys_mbox *sys_mbox_t; +typedef struct sys_sem *sys_sem_t; +typedef struct sys_thread *sys_thread_t; + + +#endif /* NL_LWIP_LINUX_ARCH_SYS_ARCH_H */
diff --git a/products/antigua/lwip.mak b/products/antigua/lwip.mak new file mode 100644 index 0000000..87a7ec1 --- /dev/null +++ b/products/antigua/lwip.mak
@@ -0,0 +1,20 @@ +# +# Copyright (c) 2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file adds product-specific header search paths to LwIP. +# + +lwip_INCLUDES += $(FreeRTOSConfigDir) \ + $(FreeRTOSIncludePaths) \ + $(NewLibCIncludePaths) \ + $(WicedIncludePaths) +
diff --git a/products/antigua/lwipopts.h b/products/antigua/lwipopts.h new file mode 100644 index 0000000..034dae3 --- /dev/null +++ b/products/antigua/lwipopts.h
@@ -0,0 +1,326 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * Description: + * This file describes compile-time constants used for + * configuring LwIP. + * + */ + +/* + * Copyright 2012, Broadcom Corporation + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of Broadcom Corporation. + */ + +/* + * 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 __ANTIGUA_LWIPOPTS_H__ +#define __ANTIGUA_LWIPOPTS_H__ + +#include <stdlib.h> + +#include <network/wwd_network_constants.h> + +#include "common/lwipopts.h" +#include "nlertaskpriority.h" + +#ifdef CUSTOM_LWIPOPTS +#include "custom_lwipopts.h" +#else /* ifdef CUSTOM_LWIPOPTS */ + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#define MEM_ALIGNMENT (4) + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETBUF (PBUF_POOL_SIZE_LARGE) + + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN+1) + +/** + * MEMP_SEPARATE_POOLS: if defined to 1, each pool is placed in its own array. + * This can be used to individually change the location of each pool. + * Default is one big array for all pools + * + * Nest has enabled this flag to support pbuf allocation tracking. + */ +#define MEMP_SEPARATE_POOLS (1) + +/** + * LWIP_PBUF_FROM_CUSTOM_POOLS: Declare a set of custom mempools immediately following + * MEMP_PBUF_POOL. When allocating a pbuf, scan the custom pbuf pools and find the + * smallest free pbuf that will hold the requested payload and allocate from that pool. + * When using, set PBUF_POOL_SIZE and PBUF_POOL_BUFSIZE to 0 - they are not used. + */ +#define LWIP_PBUF_FROM_CUSTOM_POOLS (1) + +/** + * Include custom mempools from lwippools.h. Required for use with + * LWIP_PBUF_FROM_CUSTOM_POOLS + */ +#define MEMP_USE_CUSTOM_POOLS (1) + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + * + * This is just a default designed to be overriden by the FreeRTOS.mk makefile + * To perform this override, define the makefile variable LWIP_NUM_PACKET_BUFFERS_IN_POOL + */ +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE (0) +#endif + +//TODO: ANT-220: Adjust pbuf pool sizes +/** + * PBUF_POOL_SIZE_LARGE: the number of buffers in the pool for large sized pbufs + */ +#define PBUF_POOL_SIZE_LARGE (10) + +/** + * PBUF_POOL_SIZE_MEDIUM: the number of buffers in the pool for medium sized pbufs + */ +#define PBUF_POOL_SIZE_MEDIUM (4) + +/** + * PBUF_POOL_SIZE_SMALL: the number of buffers in the pool for small sized pbufs + */ +#define PBUF_POOL_SIZE_SMALL (8) + +/* + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + * + */ +#if PBUF_POOL_SIZE_LARGE > 2 +#ifndef IP_REASS_MAX_PBUFS +#define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE_LARGE - 2) +#endif +#else +#define IP_REASS_MAX_PBUFS 0 +#define IP_REASSEMBLY 0 +#endif + +/** + * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for + * reassembly (whole packets, not fragments!) + */ +#if IP_REASS_MAX_PBUFS > 1 +#ifndef MEMP_NUM_REASSDATA +#define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1) +#endif +#else +#define MEMP_NUM_REASSDATA 0 +#endif + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + */ +// Make a bigger pbuf, wifi passthru wants a 0x624 +#define PBUF_SIZE 0x640 +//#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(WICED_LINK_MTU) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) +#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(PBUF_SIZE) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) + +//TODO: ANT-220: Adjust pbuf pool sizes +/** + * PBUF_POOL_BUFSIZE_LARGE: the size of each pbuf in the pool for large pbufs + */ +#define PBUF_POOL_BUFSIZE_LARGE (PBUF_POOL_BUFSIZE) + +/** + * PBUF_POOL_BUFSIZE_MEDIUM: the size of each pbuf in the pool for medium pbufs + */ +#define PBUF_POOL_BUFSIZE_MEDIUM (640) + +/** + * PBUF_POOL_BUFSIZE_MEDIUM: the size of each pbuf in the pool for small pbufs + */ +#define PBUF_POOL_BUFSIZE_SMALL (256) + +/** + * PBUF_CUSTOM_POOL_IDX_START: the pbuf pool index at which we start scanning when + * searching variable sized pbuf pools for one we can use. Scanning begins at + * PBUF_CUSTOM_POOL_IDX_START and stops when we reach PBUF_VARIABLE_POOL_END. Pools should be + * placed in descending order by size, immediately following the MEMP_PBUF_POOL. + * + * ie, + * MEMP_PBUF_POOL <---- default pool of pbufs, defined to be zero size + * CUSTOM_PBUF_POOL_0 <---- pool containing largest pbufs + * CUSTOM_PBUF_POOL_1 <---- pool containing second largest pbufs + * ... + * CUSTOM_PBUF_POOL_N-1 <---- pool containing second smallest pbufs + * CUSTOM_PBUF_POOL_N <---- pool containing smallest pbufs. + * + * PBUF_CUSTOM_POOL_IDX_START would be defined to CUSTOM_PBUF_POOL_N + * PBUF_CUSTOM_POOL_IDX_END would be defined to CUSTOM_PBUF_POOL_0 + */ +#define PBUF_CUSTOM_POOL_IDX_START (MEMP_PBUF_POOL_SMALL) +#define PBUF_CUSTOM_POOL_IDX_END (MEMP_PBUF_POOL_LARGE) + +/** + * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + * per active UDP "connection". + * (requires the LWIP_UDP option) + * LWIP_DHCP and LWIP_DNS are used by LWIP, and the 6 are used by UDP endpoints in InetLayer. + * + * See #INET_CONFIG_NUM_UDP_ENDPOINTS for InetLayer configuration. + */ +#ifdef MEMP_NUM_UDP_PCB +#undef MEMP_NUM_UDP_PCB +#define MEMP_NUM_UDP_PCB (6 + (LWIP_DHCP) + (LWIP_DNS)) +#endif + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +/* *** IMPORTANT *** + * + * DO NOT increase this beyond the point at which a TCP segement will fit within a single PBUF, otherwise + * the code in the WICED netif output function (host_hardware_output() in wiced-network.cpp) will fail. + * + * The limit is effectively WICED_LINK_MTU - (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME + WICED_ETHERNET_SIZE + 60) + */ +#define TCP_MSS (1152) + + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * must be at least as much as (2 * TCP_MSS) for things to work smoothly + */ +#define TCP_SND_BUF (6 * TCP_MSS) + +/** + * ETH_PAD_SIZE: the header space required preceeding the of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + * + * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed + */ +#define ETH_PAD_SIZE (0) + +#define SUB_ETHERNET_HEADER_SPACE (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME) + + +/** + * PBUF_LINK_HLEN: the number of bytes that should be allocated for a + * link level header. The default is 14, the standard value for + * Ethernet. + */ +#define PBUF_LINK_HLEN (WICED_PHYSICAL_HEADER) + + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#define TCPIP_THREAD_STACKSIZE (1300) + + +/** + * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + * Note: If this task priority is modified, please update the comment in nlenvironment-common.h + */ +#define TCPIP_THREAD_PRIO ((NLER_TASK_PRIORITY_HIGHEST)-4) //5 + +#define TCP_LISTEN_BACKLOG (1) + + +/** + * The WICED definition of PBUF_POOL_BUFSIZE includes a number of + * sizeof() instantiations which causes the C preprocessor to + * fail. Disable TCP configuration constant sanity checks to work + * around this. + */ +#define LWIP_DISABLE_TCP_SANITY_CHECKS (1) + +/** + * The maximum of all used hardware address lengths across all types + * of interfaces in use: + * + * - 802.11 : 6 + * - 802.15.4 : 8 + */ +#define NETIF_MAX_HWADDR_LEN 8U + +#define LWIP_NOASSERT 1 + +/** + * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs + */ +#define LWIP_IPV6_FORWARD 1 + +#endif /* ifdef CUSTOM_LWIPOPTS */ + +/* + * LWIP_IPV6_FORWARD==1: Enable IPv6 forwarding. + */ +#ifndef LWIP_IPV6_FORWARD +#define LWIP_IPV6_FORWARD 1 +#endif + +/** + * LWIP_IPV6_ROUTE_TABLE_SUPPORT==1: Enable support for a static routing table and refering + * these during forwarding. + */ +#ifndef LWIP_IPV6_ROUTE_TABLE_SUPPORT +#define LWIP_IPV6_ROUTE_TABLE_SUPPORT 1 +#endif + +#endif /* __ANTIGUA_LWIPOPTS_H__ */
diff --git a/products/antiguasim/lwip.mak b/products/antiguasim/lwip.mak new file mode 100644 index 0000000..f6ecd78 --- /dev/null +++ b/products/antiguasim/lwip.mak
@@ -0,0 +1,19 @@ +# +# Copyright (c) 2017 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file adds product-specific header search paths to LwIP. +# + +lwip_INCLUDES += $(FreeRTOSConfigDir) \ + $(FreeRTOSIncludePaths) \ + $(NewLibCIncludeDir) +
diff --git a/products/antiguasim/lwipopts.h b/products/antiguasim/lwipopts.h new file mode 100644 index 0000000..5cdb1f5 --- /dev/null +++ b/products/antiguasim/lwipopts.h
@@ -0,0 +1,224 @@ +/* + * + * Copyright (c) 2012-2017 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + */ + +/** + * @file + * This file describes compile-time constants used for + * configuring LwIP. + * + */ + +/* + * Copyright 2012, Broadcom Corporation + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of Broadcom Corporation. + */ + +/* + * 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 __ANTIGUASIM_LWIPOPTS_H__ +#define __ANTIGUASIM_LWIPOPTS_H__ + +#include <stdlib.h> + +#include "common/lwipopts.h" +#include "nlertaskpriority.h" + +#ifdef CUSTOM_LWIPOPTS +#include "custom_lwipopts.h" +#else /* ifdef CUSTOM_LWIPOPTS */ + + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#define MEM_ALIGNMENT (4) + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETBUF (PBUF_POOL_SIZE) + + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN+1) + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + * + * This is just a default designed to be overriden by the FreeRTOS.mk makefile + * To perform this override, define the makefile variable LWIP_NUM_PACKET_BUFFERS_IN_POOL + */ +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE (12) +#endif + +/* + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + * + */ +#if PBUF_POOL_SIZE > 2 +#ifndef IP_REASS_MAX_PBUFS +#define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - 2) +#endif +#else +#define IP_REASS_MAX_PBUFS 0 +#define IP_REASSEMBLY 0 +#endif + +/** + * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for + * reassembly (whole packets, not fragments!) + */ +#if IP_REASS_MAX_PBUFS > 1 +#ifndef MEMP_NUM_REASSDATA +#define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1) +#endif +#else +#define MEMP_NUM_REASSDATA 0 +#endif + + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + */ +// Make a bigger pbuf, wifi passthru wants a 0x624 +#define PBUF_SIZE 0x640 +//#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(WICED_LINK_MTU) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) +#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(PBUF_SIZE) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) + + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +/* *** IMPORTANT *** + * + * DO NOT increase this beyond the point at which a TCP segement will fit within a single PBUF, otherwise + * the code in the WICED netif output function (host_hardware_output() in wiced-network.cpp) will fail. + * + * The limit is effectively WICED_LINK_MTU - (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME + WICED_ETHERNET_SIZE + 60) + */ +#define TCP_MSS (1152) + + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * must be at least as much as (2 * TCP_MSS) for things to work smoothly + */ +#define TCP_SND_BUF (6 * TCP_MSS) + +/** + * ETH_PAD_SIZE: the header space required preceeding the of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + * + * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed + */ +#define ETH_PAD_SIZE (0) + +#define SUB_ETHERNET_HEADER_SPACE (8 + 12 + 4 + 2) + + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#define TCPIP_THREAD_STACKSIZE (1300) + + +/** + * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + * Note: If this task priority is modified, please update the comment in nlenvironment-common.h + */ +#define TCPIP_THREAD_PRIO ((NLER_TASK_PRIORITY_HIGHEST)-4) //5 + +#define TCP_LISTEN_BACKLOG (1) + + +/** + * The WICED definition of PBUF_POOL_BUFSIZE includes a number of + * sizeof() instantiations which causes the C preprocessor to + * fail. Disable TCP configuration constant sanity checks to work + * around this. + */ +#define LWIP_DISABLE_TCP_SANITY_CHECKS (1) + +/** + * The maximum of all used hardware address lengths across all types + * of interfaces in use: + * + * - 802.11 : 6 + * - 802.15.4 : 8 + */ +#define NETIF_MAX_HWADDR_LEN 8U + +#define LWIP_NOASSERT 1 + +#undef LWIP_TEST_CODE +#define LWIP_TEST_CODE 1 + +#endif /* ifdef CUSTOM_LWIPOPTS */ + +#endif /* __ANTIGUASIM_LWIPOPTS_H__ */
diff --git a/products/common/lwipopts.h b/products/common/lwipopts.h new file mode 100644 index 0000000..0c7fde1 --- /dev/null +++ b/products/common/lwipopts.h
@@ -0,0 +1,374 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * Description: + * This file describes common compile-time constants used for + * configuring LwIP, shared across all products and platforms. + * + */ + +#ifndef __COMMON_LWIPOPTS_H__ +#define __COMMON_LWIPOPTS_H__ + +/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided + * by your system, set this to 0 and include <sys/time.h> in cc.h + */ +#define LWIP_TIMEVAL_PRIVATE (0) + +/** + * LwIP has three memory models it can work with for general memory + * allocation: + * + * 1) Standard C Library APIs and default platform heap. + * + * - Enabled by asserting MEM_LIBC_MALLOC + * + * 2) LwIP APIs and LwIP-internal heap (from BSS data). + * + * - Enabled by deasserting MEM_LIBC_MALLOC + * + * 3) Pre-allocated binned memory and object pools (from BSS data). + * + * - Enabled by deasserting MEM_LIBC_MALLOC and asserting + * MEM_USE_POOLS. + * + */ + +/** + * Do use the Standard C Library heap and associated APIs. + */ +#define MEM_LIBC_MALLOC (0) + +/** + * Do not use memory pools to create fixed, statically allocated pools of + * memory in lieu of the Standard C Library heap and APIs. + */ +#define MEM_USE_POOLS (0) + +/** + * Do not use custom memory pools for specific, named LwIP objects, sourced + * from lwippools.h. + */ +#define MEM_USE_CUSTOM_POOLS (MEM_USE_POOLS) + +/** + * MEM_SIZE: The size of the built-in LwIP heap memory. + * + * We size this for: + * + * 1 @ 1500 bytes for maximally-sized MTU + * 2 @ 120 bytes for outstanding transport header + * 2 @ 132 bytes for outstanding IPv6 NDP packets + * 5 @ 9 bytes for LwIP heap structure + * + * 2409 + 16 byte alignment -> 2064 + */ +#define MEM_SIZE 2064 + +/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores + * should be used instead + */ +#define LWIP_COMPAT_MUTEX (1) + +/** + * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain + * critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#define SYS_LIGHTWEIGHT_PROT (1) + +/** + * LWIP_DHCP==1: Enable DHCP module. + */ +#define LWIP_DHCP (1) + +/** + * Enable automatic IPv4 link-local address assignment. + */ +#define LWIP_AUTOIP (1) + +/** + * Allow DHCP and automatic IPv4 link-local address assignment to + * work cooperatively. + */ +#define LWIP_DHCP_AUTOIP_COOP (0) + +/** + * LWIP_PROVIDE_ERRNO: errno definitions from the Standard C Library. + */ +#undef LWIP_PROVIDE_ERRNO + +/** + * ERRNO: set errno on interface invocation failures + */ +#define ERRNO (1) + +/** + * MEMP_NUM_RAW_PCB: Number of raw connection PCBs + * (requires the LWIP_RAW option) + */ +#ifndef MEMP_NUM_RAW_PCB +#define MEMP_NUM_RAW_PCB (5) +#endif + +/** + * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + * per active UDP "connection". + * (requires the LWIP_UDP option) + * LWIP_DHCP and LWIP_DNS are used by LWIP, and the 5 are used by UDP endpoints in InetLayer. + * + * See #INET_CONFIG_NUM_UDP_ENDPOINTS for InetLayer configuration. + */ +#ifndef MEMP_NUM_UDP_PCB +#define MEMP_NUM_UDP_PCB (5 + (LWIP_DHCP) + (LWIP_DNS)) +#endif + +/* ARP before DHCP causes multi-second delay - turn it off */ +#define DHCP_DOES_ARP_CHECK (0) + +/** + * 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 (0) + +/** + * MEMP_NUM_NETCONN: the number of struct netconns. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETCONN (1) + +/** + * LWIP_SO_RCVTIMEO==1: Enable SO_RCVTIMEO processing. + */ +#define LWIP_SO_RCVTIMEO (1) + + +/** + * LWIP_IGMP==1: Turn on IGMP module. + */ +#define LWIP_IGMP (1) + + +/** + * SO_REUSE==1: Enable SO_REUSEADDR option. + * Required by IGMP for reuse of multicast address and port by other sockets + */ +#define SO_REUSE (1) + +/** + * When using IGMP, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value + */ +#define LWIP_RAND() (u32_t)lrand48() + +/** + * LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: Randomize the local port + * for the first local TCP/UDP PCB. This can prevent creating + * predictable port numbers after booting a system (see RFC-6065). + */ +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS (1) + +/** + * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS + * transport. + */ +#define LWIP_DNS (1) +#define LWIP_DNS_RAND_ID (1) + +/** + * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names. + * Disable this option if you use a POSIX operating system that uses the same + * names (read, write & close). (only used if you use sockets.c) + * + * We disable this because this otherwise collides with the Standard C + * Library where both LWIP and its headers are included. + */ +#define LWIP_POSIX_SOCKETS_IO_NAMES (0) + +#ifdef LWIP_SO_RCVBUF +#if ( LWIP_SO_RCVBUF == 1 ) +#include <limits.h> /* Needed because RECV_BUFSIZE_DEFAULT is defined as INT_MAX */ +#endif /* if ( LWIP_SO_RCVBUF == 1 ) */ +#endif /* ifdef LWIP_SO_RCVBUF */ + +/** + * LWIP_STATS : Turn off statistics gathering + */ +#define LWIP_STATS (0) + +#ifdef BUILD_FEATURE_NETWORK_STATS +#undef LWIP_STATS +#define LWIP_STATS 1 +#define LWIP_STATS_DISPLAY 1 +#undef MEMP_STATS +#define MEMP_STATS 1 +#endif + + +/** + * LWIP_IPV6==1: Enable IPv6 + */ +#define LWIP_IPV6 1 + +/** + * LWIP_IPV6_AUTOCONFIG==0: Disable stateless address + * autoconfiguration (SLAAC). + */ +#define LWIP_IPV6_AUTOCONFIG (0) + + +/** + * LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif. + * Currently: + * Link-Local, Mesh-Local, Weave Legacy ULA, Weave Thread ULA + * + * TODO: We actually don't use the Mesh-Local address, so we can reuse this slot and retain 3 addresses + */ +#define LWIP_IPV6_NUM_ADDRESSES 4 + +/** + * LWIP_IPV6_DHCP6==0: Disable DHCPv6 stateful address autoconfiguration. + */ +#ifndef LWIP_IPV6_DHCP6 +#define LWIP_IPV6_DHCP6 1 +#endif + +/** + * Enable locking in the lwip (tcpip) thread. + */ +#ifndef LWIP_TCPIP_CORE_LOCKING +#define LWIP_TCPIP_CORE_LOCKING 1 +#endif + +/** + * Controls if TCP should queue segments that arrive out of + * order. Define to 0 if your device is low on memory. + * This had been disabled for DOLO-738 (pbuf scarcity apparently + * had a bad effect on download times). + * We are enabling it again for TOPAZ-3661 (OTA downloads are + * timing out because our CDN now requires the devices to + * store out-of-sequence segments; otherwise the F-RTO Recovery + * algorithm on the sender side does not work and the download stalls). + * We don't see the problem mentioned in DOLO-738 anymore. + */ +#define TCP_QUEUE_OOSEQ 1 + +/** + * ARP_QUEUEING==1: Multiple outgoing packets are queued during + * hardware address resolution. By default, only the most recent + * packet is queued per IP address. This is sufficient for most + * protocols and mainly reduces TCP connection startup time. Set this + * to 1 if you know your application sends more than one packet in a + * row to an IP address that is not in the ARP cache. + */ +#define ARP_QUEUEING (0) + +/** + * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing + * packets (pbufs) that are waiting for an ARP request (to resolve + * their destination address) to finish. (requires the ARP_QUEUEING + * option) + */ +#define MEMP_NUM_ARP_QUEUE (PBUF_POOL_SIZE) + +/** + * LWIP_ND6_QUEUEING==1: queue outgoing IPv6 packets while MAC address + * is being resolved. + */ +#define LWIP_ND6_QUEUEING (LWIP_IPV6) + +/** + * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC + * resolution. + */ +#define MEMP_NUM_ND6_QUEUE (PBUF_POOL_SIZE) + +/** + * LWIP_MULTICAST_PING: respond to multicast pings (default is unicast only) + */ +#define LWIP_MULTICAST_PING (1) + +/** + * Debug printing + * By default enable debug printing for debug build, but set level to off + * This allows user to change any desired debug level to on. + */ +#ifdef DEBUG +#undef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK ( 0 ) +#define MEMP_SANITY_CHECK ( 0 ) +#define MEM_DEBUG (LWIP_DBG_OFF) +#define MEMP_DEBUG (LWIP_DBG_OFF) +#define PBUF_DEBUG (LWIP_DBG_OFF) +#define API_LIB_DEBUG (LWIP_DBG_OFF) +#define API_MSG_DEBUG (LWIP_DBG_OFF) +#define TCPIP_DEBUG (LWIP_DBG_OFF) +#define NETIF_DEBUG (LWIP_DBG_OFF) +#define SOCKETS_DEBUG (LWIP_DBG_OFF) +#define DEMO_DEBUG (LWIP_DBG_OFF) +#define DHCP_DEBUG (LWIP_DBG_OFF) +#define AUTOIP_DEBUG (LWIP_DBG_OFF) +#define ETHARP_DEBUG (LWIP_DBG_OFF) +#define IP_DEBUG (LWIP_DBG_OFF) +#define IP_REASS_DEBUG (LWIP_DBG_OFF) +#define IP6_DEBUG (LWIP_DBG_OFF) +#define RAW_DEBUG (LWIP_DBG_OFF) +#define ICMP_DEBUG (LWIP_DBG_OFF) +#define UDP_DEBUG (LWIP_DBG_OFF) +#define TCP_DEBUG (LWIP_DBG_OFF) +#define TCP_INPUT_DEBUG (LWIP_DBG_OFF) +#define TCP_OUTPUT_DEBUG (LWIP_DBG_OFF) +#define TCP_RTO_DEBUG (LWIP_DBG_OFF) +#define TCP_CWND_DEBUG (LWIP_DBG_OFF) +#define TCP_WND_DEBUG (LWIP_DBG_OFF) +#define TCP_FR_DEBUG (LWIP_DBG_OFF) +#define TCP_QLEN_DEBUG (LWIP_DBG_OFF) +#define TCP_RST_DEBUG (LWIP_DBG_OFF) +#define PPP_DEBUG (LWIP_DBG_OFF) + +#define LWIP_DBG_TYPES_ON (LWIP_DBG_OFF) /* (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) */ +#endif + +/** + * LwIP defaults the size of most mailboxes (i.e. message queues) to + * zero (0). That generally makes RTOSes such as FreeRTOS very + * unhappy. Specify reasonable defaults instead. + */ +#define TCPIP_MBOX_SIZE 6 + +#define DEFAULT_RAW_RECVMBOX_SIZE 6 + +#define DEFAULT_UDP_RECVMBOX_SIZE 6 + +#define DEFAULT_TCP_RECVMBOX_SIZE 6 + +/** + * Disable processing of incoming Router Advertisements. + */ +#define LWIP_ND6_LISTEN_RA 0 + +/** + * Disable IPV6 router discovery. + */ +#define LWIP_IPV6_ROUTER_SUPPORT 0 + +/** + * Enable TCP keepalives, for Weave WDM subscriptions + */ +#define LWIP_TCP_KEEPALIVE 1 + +/** + * Limit the DNS TTL to 15 minutes. + * The value is in seconds. + */ + +#define DNS_MAX_TTL (60 * 15) + +#endif /* __COMMON_LWIPOPTS_H__ */
diff --git a/products/lwipopts.h b/products/lwipopts.h new file mode 100644 index 0000000..8b8fdc8 --- /dev/null +++ b/products/lwipopts.h
@@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * Description: + * This file describes compile-time constants used for + * configuring LwIP. + * + */ + +#ifndef __LWIPOPTS_H__ +#define __LWIPOPTS_H__ + +#if defined(BUILD_PRODUCT_SIMULATOR) +#include <simulator/lwipopts.h> + +#elif defined(BUILD_PRODUCT_TOPAZ) +#include <topaz/lwipopts.h> + +#elif defined(BUILD_PRODUCT_TOWER) +#include <tower/lwipopts.h> + +#elif defined(BUILD_PRODUCT_T2) +#include <t2/lwipopts.h> + +#elif defined(BUILD_PRODUCT_T2SIM) +#include <t2sim/lwipopts.h> + +#elif defined(BUILD_PRODUCT_ANTIGUA) +#include <antigua/lwipopts.h> + +#elif defined(BUILD_PRODUCT_ANTIGUASIM) +#include <antiguasim/lwipopts.h> + +#else +#error lwipopts.h must define a BUILD_PRODUCT +#endif + +#endif /* __LWIPOPTS_H__ */
diff --git a/products/lwippools.h b/products/lwippools.h new file mode 100644 index 0000000..b2e42cb --- /dev/null +++ b/products/lwippools.h
@@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4 indent-tabs-mode: nil -*- + * + * Copyright (c) 2013 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + * Description: + * This file defines statically-allocated pools of memory that + * are used by LwIP in lieu of the Standard C Library heap. + * + * In lwipopts.h, define MEM_USE_POOLS to use the standard set + * of size-based pools and define MEMP_USE_CUSTOM_POOLS to use + * custom, named pools. + * + */ + +/* Define pools in increasing order according to the pool element + * size. + * + * LWIP_MALLOC_MEMPOOL(number_elements, element_size) + */ + +#if MEM_USE_POOLS + +#endif /* MEM_USE_POOLS */ + +/* Define pools in increasing order according to the pool element + * size. + * + * LWIP_MEMPOOL(name, number_elements, element_size, description) + */ + +#if MEMP_USE_CUSTOM_POOLS + +/* Custom PBUF pools must be defined starting with the pool containing the largest PBUF, + * and must be allocated in descending order by PBUF size. + * + * pbuf_alloc will start at the smallest pool (PBUF_VARIABLE_POOL_START in lwipopts.h) + * and try to allocate from pbuf pools of progressively larger pbuf size until it + * successfully finds a pbuf from one of the pools or until it passes PBUF_VARIABLE_POOL_END*/ + +#if LWIP_PBUF_FROM_CUSTOM_POOLS +LWIP_PBUF_MEMPOOL(PBUF_POOL_LARGE, PBUF_POOL_SIZE_LARGE, PBUF_POOL_BUFSIZE_LARGE, "PBUF_POOL_LARGE") +LWIP_PBUF_MEMPOOL(PBUF_POOL_MEDIUM, PBUF_POOL_SIZE_MEDIUM, PBUF_POOL_BUFSIZE_MEDIUM, "PBUF_POOL_MEDIUM") +LWIP_PBUF_MEMPOOL(PBUF_POOL_SMALL, PBUF_POOL_SIZE_SMALL, PBUF_POOL_BUFSIZE_SMALL, "PBUF_POOL_SMALL") +#endif + +/* Place other custom LWIP mem pools below this line */ + +#endif /* MEMP_USE_CUSTOM_POOLS */
diff --git a/products/t2/lwip.mak b/products/t2/lwip.mak new file mode 100644 index 0000000..87a7ec1 --- /dev/null +++ b/products/t2/lwip.mak
@@ -0,0 +1,20 @@ +# +# Copyright (c) 2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file adds product-specific header search paths to LwIP. +# + +lwip_INCLUDES += $(FreeRTOSConfigDir) \ + $(FreeRTOSIncludePaths) \ + $(NewLibCIncludePaths) \ + $(WicedIncludePaths) +
diff --git a/products/t2/lwipopts.h b/products/t2/lwipopts.h new file mode 100644 index 0000000..9548bb0 --- /dev/null +++ b/products/t2/lwipopts.h
@@ -0,0 +1,253 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * Description: + * This file describes compile-time constants used for + * configuring LwIP. + * + */ + +/* + * Copyright 2012, Broadcom Corporation + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of Broadcom Corporation. + */ + +/* + * 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 __T2_LWIPOPTS_H__ +#define __T2_LWIPOPTS_H__ + +#include <stdlib.h> + +#include <network/wwd_network_constants.h> + +#include "common/lwipopts.h" +#include "nlertaskpriority.h" + +#ifdef CUSTOM_LWIPOPTS +#include "custom_lwipopts.h" +#else /* ifdef CUSTOM_LWIPOPTS */ + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#define MEM_ALIGNMENT (4) + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETBUF (PBUF_POOL_SIZE) + + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN+1) + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + * + * This is just a default designed to be overriden by the FreeRTOS.mk makefile + * To perform this override, define the makefile variable LWIP_NUM_PACKET_BUFFERS_IN_POOL + */ +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE (12) +#endif + +/* + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + * + */ +#if PBUF_POOL_SIZE > 2 +#ifndef IP_REASS_MAX_PBUFS +#define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - 2) +#endif +#else +#define IP_REASS_MAX_PBUFS 0 +#define IP_REASSEMBLY 0 +#endif + +/** + * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for + * reassembly (whole packets, not fragments!) + */ +#if IP_REASS_MAX_PBUFS > 1 +#ifndef MEMP_NUM_REASSDATA +#define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1) +#endif +#else +#define MEMP_NUM_REASSDATA 0 +#endif + + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + */ +// Make a bigger pbuf, wifi passthru wants a 0x624 +#define PBUF_SIZE 0x640 +//#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(WICED_LINK_MTU) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) +#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(PBUF_SIZE) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) + + +/** + * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + * per active UDP "connection". + * (requires the LWIP_UDP option) + * LWIP_DHCP and LWIP_DNS are used by LWIP, and the 6 are used by UDP endpoints in InetLayer. + * + * See #INET_CONFIG_NUM_UDP_ENDPOINTS for InetLayer configuration. + */ +#ifdef MEMP_NUM_UDP_PCB +#undef MEMP_NUM_UDP_PCB +#define MEMP_NUM_UDP_PCB (6 + (LWIP_DHCP) + (LWIP_DNS)) +#endif + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +/* *** IMPORTANT *** + * + * DO NOT increase this beyond the point at which a TCP segement will fit within a single PBUF, otherwise + * the code in the WICED netif output function (host_hardware_output() in wiced-network.cpp) will fail. + * + * The limit is effectively WICED_LINK_MTU - (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME + WICED_ETHERNET_SIZE + 60) + */ +#define TCP_MSS (1152) + + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * must be at least as much as (2 * TCP_MSS) for things to work smoothly + */ +#define TCP_SND_BUF (6 * TCP_MSS) + +/** + * ETH_PAD_SIZE: the header space required preceeding the of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + * + * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed + */ +#define ETH_PAD_SIZE (0) + +#define SUB_ETHERNET_HEADER_SPACE (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME) + + +/** + * PBUF_LINK_HLEN: the number of bytes that should be allocated for a + * link level header. The default is 14, the standard value for + * Ethernet. + */ +#define PBUF_LINK_HLEN (WICED_PHYSICAL_HEADER) + + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#define TCPIP_THREAD_STACKSIZE (1300) + + +/** + * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + * Note: If this task priority is modified, please update the comment in nlenvironment-common.h + */ +#define TCPIP_THREAD_PRIO ((NLER_TASK_PRIORITY_HIGHEST)-4) //5 + +#define TCP_LISTEN_BACKLOG (1) + + +/** + * The WICED definition of PBUF_POOL_BUFSIZE includes a number of + * sizeof() instantiations which causes the C preprocessor to + * fail. Disable TCP configuration constant sanity checks to work + * around this. + */ +#define LWIP_DISABLE_TCP_SANITY_CHECKS (1) + +/** + * The maximum of all used hardware address lengths across all types + * of interfaces in use: + * + * - 802.11 : 6 + * - 802.15.4 : 8 + */ +#define NETIF_MAX_HWADDR_LEN 8U + +#define LWIP_NOASSERT 1 + +/** + * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs + */ +#define LWIP_IPV6_FORWARD 1 + +#endif /* ifdef CUSTOM_LWIPOPTS */ + +/* + * LWIP_IPV6_FORWARD==1: Enable IPv6 forwarding. + */ +#ifndef LWIP_IPV6_FORWARD +#define LWIP_IPV6_FORWARD 1 +#endif + +/** + * LWIP_IPV6_ROUTE_TABLE_SUPPORT==1: Enable support for a static routing table and refering + * these during forwarding. + */ +#ifndef LWIP_IPV6_ROUTE_TABLE_SUPPORT +#define LWIP_IPV6_ROUTE_TABLE_SUPPORT 1 +#endif + +#endif /* __T2_LWIPOPTS_H__ */
diff --git a/products/t2sim/lwip.mak b/products/t2sim/lwip.mak new file mode 100644 index 0000000..8ec684f --- /dev/null +++ b/products/t2sim/lwip.mak
@@ -0,0 +1,19 @@ +# +# Copyright (c) 2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file adds product-specific header search paths to LwIP. +# + +lwip_INCLUDES += $(FreeRTOSConfigDir) \ + $(FreeRTOSIncludePaths) \ + $(NewLibCIncludeDir) +
diff --git a/products/t2sim/lwipopts.h b/products/t2sim/lwipopts.h new file mode 100644 index 0000000..5af7be5 --- /dev/null +++ b/products/t2sim/lwipopts.h
@@ -0,0 +1,224 @@ +/* + * + * Copyright (c) 2012-2014 Nest Labs, Inc. + * All rights reserved. + * + * This document is the property of Nest. It is considered + * confidential and proprietary information. + * + * This document may not be reproduced or transmitted in any form, + * in whole or in part, without the express written permission of + * Nest. + * + */ + +/** + * @file + * This file describes compile-time constants used for + * configuring LwIP. + * + */ + +/* + * Copyright 2012, Broadcom Corporation + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of Broadcom Corporation. + */ + +/* + * 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 __T2SIM_LWIPOPTS_H__ +#define __T2SIM_LWIPOPTS_H__ + +#include <stdlib.h> + +#include "common/lwipopts.h" +#include "nlertaskpriority.h" + +#ifdef CUSTOM_LWIPOPTS +#include "custom_lwipopts.h" +#else /* ifdef CUSTOM_LWIPOPTS */ + + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#define MEM_ALIGNMENT (4) + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETBUF (PBUF_POOL_SIZE) + + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN+1) + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + * + * This is just a default designed to be overriden by the FreeRTOS.mk makefile + * To perform this override, define the makefile variable LWIP_NUM_PACKET_BUFFERS_IN_POOL + */ +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE (12) +#endif + +/* + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + * + */ +#if PBUF_POOL_SIZE > 2 +#ifndef IP_REASS_MAX_PBUFS +#define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - 2) +#endif +#else +#define IP_REASS_MAX_PBUFS 0 +#define IP_REASSEMBLY 0 +#endif + +/** + * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for + * reassembly (whole packets, not fragments!) + */ +#if IP_REASS_MAX_PBUFS > 1 +#ifndef MEMP_NUM_REASSDATA +#define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1) +#endif +#else +#define MEMP_NUM_REASSDATA 0 +#endif + + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + */ +// Make a bigger pbuf, wifi passthru wants a 0x624 +#define PBUF_SIZE 0x640 +//#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(WICED_LINK_MTU) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) +#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(PBUF_SIZE) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) + + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +/* *** IMPORTANT *** + * + * DO NOT increase this beyond the point at which a TCP segement will fit within a single PBUF, otherwise + * the code in the WICED netif output function (host_hardware_output() in wiced-network.cpp) will fail. + * + * The limit is effectively WICED_LINK_MTU - (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME + WICED_ETHERNET_SIZE + 60) + */ +#define TCP_MSS (1152) + + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * must be at least as much as (2 * TCP_MSS) for things to work smoothly + */ +#define TCP_SND_BUF (6 * TCP_MSS) + +/** + * ETH_PAD_SIZE: the header space required preceeding the of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + * + * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed + */ +#define ETH_PAD_SIZE (0) + +#define SUB_ETHERNET_HEADER_SPACE (8 + 12 + 4 + 2) + + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#define TCPIP_THREAD_STACKSIZE (1300) + + +/** + * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + * Note: If this task priority is modified, please update the comment in nlenvironment-common.h + */ +#define TCPIP_THREAD_PRIO ((NLER_TASK_PRIORITY_HIGHEST)-4) //5 + +#define TCP_LISTEN_BACKLOG (1) + + +/** + * The WICED definition of PBUF_POOL_BUFSIZE includes a number of + * sizeof() instantiations which causes the C preprocessor to + * fail. Disable TCP configuration constant sanity checks to work + * around this. + */ +#define LWIP_DISABLE_TCP_SANITY_CHECKS (1) + +/** + * The maximum of all used hardware address lengths across all types + * of interfaces in use: + * + * - 802.11 : 6 + * - 802.15.4 : 8 + */ +#define NETIF_MAX_HWADDR_LEN 8U + +#define LWIP_NOASSERT 1 + +#undef LWIP_TEST_CODE +#define LWIP_TEST_CODE 1 + +#endif /* ifdef CUSTOM_LWIPOPTS */ + +#endif /* __T2SIM_LWIPOPTS_H__ */
diff --git a/products/topaz/lwip.mak b/products/topaz/lwip.mak new file mode 100644 index 0000000..87a7ec1 --- /dev/null +++ b/products/topaz/lwip.mak
@@ -0,0 +1,20 @@ +# +# Copyright (c) 2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file adds product-specific header search paths to LwIP. +# + +lwip_INCLUDES += $(FreeRTOSConfigDir) \ + $(FreeRTOSIncludePaths) \ + $(NewLibCIncludePaths) \ + $(WicedIncludePaths) +
diff --git a/products/topaz/lwipopts.h b/products/topaz/lwipopts.h new file mode 100644 index 0000000..2af5a1b --- /dev/null +++ b/products/topaz/lwipopts.h
@@ -0,0 +1,220 @@ +/* + * + * Copyright (c) 2012-2013 Nest Labs, Inc. + * All rights reserved. + * + * Description: + * This file describes compile-time constants used for + * configuring LwIP. + * + */ + +/* + * Copyright 2012, Broadcom Corporation + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of Broadcom Corporation. + */ + +/* + * 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 __TOPAZ_LWIPOPTS_H__ +#define __TOPAZ_LWIPOPTS_H__ + +#include <stdlib.h> + +#include <network/wwd_network_constants.h> + +#include "common/lwipopts.h" +#include "nlertaskpriority.h" + +#ifdef CUSTOM_LWIPOPTS +#include "custom_lwipopts.h" +#else /* ifdef CUSTOM_LWIPOPTS */ + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#define MEM_ALIGNMENT (4) + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETBUF (PBUF_POOL_SIZE) + + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN+1) + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + * + * This is just a default designed to be overriden by the FreeRTOS.mk makefile + * To perform this override, define the makefile variable LWIP_NUM_PACKET_BUFFERS_IN_POOL + */ +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE (12) +#endif + +/* + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + * + */ +#if PBUF_POOL_SIZE > 2 +#ifndef IP_REASS_MAX_PBUFS +#define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - 2) +#endif +#else +#define IP_REASS_MAX_PBUFS 0 +#define IP_REASSEMBLY 0 +#endif + +/** + * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for + * reassembly (whole packets, not fragments!) + */ +#if IP_REASS_MAX_PBUFS > 1 +#ifndef MEMP_NUM_REASSDATA +#define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1) +#endif +#else +#define MEMP_NUM_REASSDATA 0 +#endif + + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + */ +// Make a bigger pbuf, wifi passthru wants a 0x624 +#define PBUF_SIZE 0x640 +//#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(WICED_LINK_MTU) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) +#define PBUF_POOL_BUFSIZE (LWIP_MEM_ALIGN_SIZE(PBUF_SIZE) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) + 1) + + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +/* *** IMPORTANT *** + * + * DO NOT increase this beyond the point at which a TCP segement will fit within a single PBUF, otherwise + * the code in the WICED netif output function (host_hardware_output() in wiced-network.cpp) will fail. + * + * The limit is effectively WICED_LINK_MTU - (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME + WICED_ETHERNET_SIZE + 60) + */ +#define TCP_MSS (1152) + + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * must be at least as much as (2 * TCP_MSS) for things to work smoothly + */ +#define TCP_SND_BUF (6 * TCP_MSS) + +/** + * ETH_PAD_SIZE: the header space required preceeding the of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + * + * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed + */ +#define ETH_PAD_SIZE (0) + +#define SUB_ETHERNET_HEADER_SPACE (WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME) + + +/** + * PBUF_LINK_HLEN: the number of bytes that should be allocated for a + * link level header. The default is 14, the standard value for + * Ethernet. + */ +#define PBUF_LINK_HLEN (WICED_PHYSICAL_HEADER) + + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#define TCPIP_THREAD_STACKSIZE (1300) + + +/** + * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + * Note: If this task priority is modified, please update the comment in nlenvironment-common.h + */ +#define TCPIP_THREAD_PRIO ((NLER_TASK_PRIORITY_HIGHEST)-4) //5 + +#define TCP_LISTEN_BACKLOG (1) + + +/** + * The WICED definition of PBUF_POOL_BUFSIZE includes a number of + * sizeof() instantiations which causes the C preprocessor to + * fail. Disable TCP configuration constant sanity checks to work + * around this. + */ +#define LWIP_DISABLE_TCP_SANITY_CHECKS (1) + +/** + * The maximum of all used hardware address lengths across all types + * of interfaces in use: + * + * - 802.11 : 6 + * - 802.15.4 : 8 + */ +#define NETIF_MAX_HWADDR_LEN 8U + +#define LWIP_NOASSERT 1 + +#endif /* ifdef CUSTOM_LWIPOPTS */ + +#endif /* __TOPAZ_LWIPOPTS_H__ */