Compare commits

..

1 Commits

Author SHA1 Message Date
sg
33955c636d Set LWIP_VERSION_RC to RC1 2016-04-27 22:04:51 +02:00
733 changed files with 19684 additions and 104625 deletions

6
.gitattributes vendored
View File

@@ -2,9 +2,3 @@
*.txt text
*.c text
*.h text
# For git archive
.gitignore export-ignore
.gitattributes export-ignore
.github export-ignore
.vscode export-ignore

View File

@@ -1,45 +0,0 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: '*'
jobs:
build:
strategy:
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
LSAN_OPTIONS: verbosity=1:log_threads=1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install check ninja-build doxygen
- name: Copy lwipcfg.h for example app
run: cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
- name: Build unit tests with make
run: make -C contrib/ports/unix/check
- name: Run unit tests
run: make -C contrib/ports/unix/check check
- name: Run cmake
run: mkdir build && cd build && cmake .. -G Ninja
- name: Build with cmake
run: cd build && cmake --build .
- name: Build docs with cmake
run: cd build && cmake --build . --target lwipdocs
- name: Validate combinations of options
run: cd contrib/ports/unix/example_app && ./iteropts.sh
- name: Build the default example app
run: |
cp contrib/examples/example_app/lwipcfg.h.example contrib/examples/example_app/lwipcfg.h
make -C contrib/ports/unix/example_app TESTFLAGS="-Wno-documentation" -j 4

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env bash
sudo apt-get install check ninja-build doxygen
cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
make -C contrib/ports/unix/check
mkdir build && cd build && cmake .. -G Ninja && cmake --build .

View File

@@ -1,124 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
branches: '*'
jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
queries: security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
#- name: Autobuild
# uses: github/codeql-action/autobuild@v3
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- run: |
./.github/workflows/codeql-buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
upload: false
id: step1
# Filter out rules with low severity or high false positve rate
# Also filter out warnings in third-party code
- name: Filter out unwanted errors and warnings
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**:cpp/path-injection
-**:cpp/world-writable-file-creation
-**:cpp/poorly-documented-function
-**:cpp/potentially-dangerous-function
-**:cpp/use-of-goto
-**:cpp/integer-multiplication-cast-to-long
-**:cpp/comparison-with-wider-type
-**:cpp/leap-year/*
-**:cpp/ambiguously-signed-bit-field
-**:cpp/suspicious-pointer-scaling
-**:cpp/suspicious-pointer-scaling-void
-**:cpp/unsigned-comparison-zero
-**/cmake*/Modules/**
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"
- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
retention-days: 5
- name: Fail if an error is found
run: |
./.github/workflows/fail_on_error.py \
${{ steps.step1.outputs.sarif-output }}/cpp.sarif

View File

@@ -1,34 +0,0 @@
#!/usr/bin/env python3
import json
import sys
# Return whether SARIF file contains error-level results
def codeql_sarif_contain_error(filename):
with open(filename, 'r') as f:
s = json.load(f)
for run in s.get('runs', []):
rules_metadata = run['tool']['driver']['rules']
if not rules_metadata:
rules_metadata = run['tool']['extensions'][0]['rules']
for res in run.get('results', []):
if 'ruleIndex' in res:
rule_index = res['ruleIndex']
elif 'rule' in res and 'index' in res['rule']:
rule_index = res['rule']['index']
else:
continue
try:
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
except IndexError as e:
print(e, rule_index, len(rules_metadata))
else:
if rule_level == 'error':
return True
return False
if __name__ == "__main__":
if codeql_sarif_contain_error(sys.argv[1]):
sys.exit(1)

79
.gitignore vendored
View File

@@ -1,67 +1,12 @@
*.o
*.so
*.a
*.exe
*lwip_unittests.xml
*.suo
*.swp
*.log
.depend*
/.vscode/ipch
/doc/doxygen/output/html
/test/fuzz/output
/test/fuzz/lwip_fuzz
/test/fuzz/lwip_fuzz2
/test/fuzz/lwip_fuzz3
/test/fuzz/.depend
/build
/contrib/examples/example_app/lwipcfg.h
/contrib/examples/example_app/lwipopts_test.h
/contrib/ports/unix/example_app/build
/contrib/ports/unix/example_app/example_app
/contrib/ports/unix/example_app/makefsdata
/contrib/ports/unix/check/build
/contrib/ports/unix/lib/build
/contrib/ports/unix/check/lwip_unittests
/contrib/ports/win32/example_app/build
/contrib/ports/win32/lwipcfg_msvc.h
/contrib/ports/win32/msvc/Debug
/contrib/ports/win32/msvc/Debug unittests
/contrib/ports/win32/msvc/Debug fuzz
/contrib/ports/win32/msvc/Debug fuzz2
/contrib/ports/win32/msvc/Debug fuzz3
/contrib/ports/win32/msvc/Release
/contrib/ports/win32/msvc/Release unittests
/contrib/ports/win32/msvc/Release fuzz
/contrib/ports/win32/msvc/Release fuzz2
/contrib/ports/win32/msvc/x64
/contrib/ports/win32/msvc/*.user
/contrib/ports/win32/msvc/*.ncb
/contrib/ports/win32/msvc/*.cache
/contrib/ports/win32/msvc/*.suo
/contrib/ports/win32/msvc/ipch
/contrib/ports/win32/msvc/*.opensdf
/contrib/ports/win32/msvc/*.sdf
/contrib/ports/win32/mingw/*.map
/contrib/ports/win32/mingw/cov-int
/contrib/ports/win32/msvc/.vs
/contrib/apps/LwipMibCompiler/.vs
/contrib/apps/LwipMibCompiler/CCodeGeneration/bin
/contrib/apps/LwipMibCompiler/CCodeGeneration/obj
/contrib/apps/LwipMibCompiler/LwipMibCompiler/bin
/contrib/apps/LwipMibCompiler/LwipMibCompiler/obj
/contrib/apps/LwipMibCompiler/LwipSnmpCodeGeneration/bin
/contrib/apps/LwipMibCompiler/LwipSnmpCodeGeneration/obj
/contrib/apps/LwipMibCompiler/MibViewer/bin
/contrib/apps/LwipMibCompiler/MibViewer/obj
/contrib/apps/LwipMibCompiler/SharpSnmpLib/bin
/contrib/apps/LwipMibCompiler/SharpSnmpLib/obj
/src/apps/snmp/LwipMibCompiler/CCodeGeneration/bin/
/src/apps/snmp/LwipMibCompiler/CCodeGeneration/obj/
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/bin/
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/obj/
/src/apps/snmp/LwipMibCompiler/LwipMibViewer/bin/
/src/apps/snmp/LwipMibCompiler/LwipMibViewer/obj/
/src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/bin/
/src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/obj/
/src/apps/snmp/LwipMibCompiler/SharpSnmpLib/bin/
/src/apps/snmp/LwipMibCompiler/SharpSnmpLib/obj/
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler.userprefs
/src/apps/snmp/LwipMibCompiler/*.suo

View File

@@ -1,28 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/src/include",
"${workspaceFolder}/contrib",
"${workspaceFolder}/contrib/examples/example_app",
"${workspaceFolder}/contrib/ports/unix/port/include",
"${workspaceFolder}/contrib/ports/unix/example_app"
],
"defines": [],
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
}

62
.vscode/launch.json vendored
View File

@@ -1,62 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch example_app",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": true,
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "Build example_app",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"linux": {
"cwd": "${workspaceFolder}/build/contrib/ports/unix/example_app",
"program": "${workspaceFolder}/build/contrib/ports/unix/example_app/example_app",
},
"windows": {
"cwd": "${workspaceFolder}/build/contrib/ports/win32/example_app",
"program": "${workspaceFolder}/build/contrib/ports/win32/example_app/example_app",
"miDebuggerPath": "gdb.exe",
}
},
{
"name": "(gdb) Launch unit tests",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": true,
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "Build unit tests",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"linux": {
"cwd": "${workspaceFolder}/contrib/ports/unix/check/build",
"program": "${workspaceFolder}/contrib/ports/unix/check/build/lwip_unittests",
},
"windows": {
"cwd": "${workspaceFolder}/contrib/ports/win32/check/build",
"program": "${workspaceFolder}/contrib/ports/win32/check/build/lwip_unittests",
"miDebuggerPath": "gdb.exe",
}
}
]
}

10
.vscode/settings.json vendored
View File

@@ -1,10 +0,0 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.associations": {
"*.h": "c"
}
}

54
.vscode/tasks.json vendored
View File

@@ -1,54 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build example_app",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/build"
},
"problemMatcher": "$gcc",
"group": {
"kind": "build",
"isDefault": true
},
"command": "cmake --build ."
},
{
"label": "Build unit tests",
"type": "shell",
"problemMatcher": "$gcc",
"group": "build",
"linux": {
"options": {
"cwd": "${workspaceFolder}/contrib/ports/unix/check/build"
},
},
"windows": {
"options": {
"cwd": "${workspaceFolder}/contrib/ports/win32/check/build"
},
},
"command": "cmake --build ."
},
{
"label": "Configure example_app",
"type": "shell",
"problemMatcher": "$gcc",
"group": "build",
"command": "cd ${workspaceFolder}; mkdir build; cd build; cmake .."
},
{
"label": "Generate documentation",
"type": "shell",
"problemMatcher": [],
"group": "none",
"options": {
"cwd": "${workspaceFolder}/build"
},
"command": "cmake --build . --target lwipdocs"
}
]
}

119
BUILDING
View File

@@ -1,119 +0,0 @@
Building lwIP
=============
lwIP uses a CMake based build system.
The CMake files in this project are designed to
be included into your own CMake files. They are
mainly variable definitions containing a list of
source files and predefined static libraries to
be linked against application code.
1) lwIP sources:
src/Filelists.cmake provides file lists containing
the lwIP core library.
The file also contains two static libraries, lwipcore
and lwipallapps, where you can link your app against.
This is the file that is useful to all lwIP users.
2) Example applications:
contrib/Filelists.cmake provides several file lists
containing the example applications.
The file also contains several static libraries
for these example apps.
This file is only useful for you, if you can use one
of the examples in your application, which is normally
not the case.
3) OS/platform port:
Usually the OS port needs to be provided by the user.
If a port to Linux, Windows or MacOS is useful for
you, you can use
contrib/ports/{win32, unix}/Filelists.cmake
that contains file lists and libraries for
these operating systems.
VARIABLES
=========
In all cases, you need to provide two variables.
"LWIP_DIR" pointing to the lwIP directory
Example:
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/lwip)
"LWIP_INCLUDE_DIRS" that contains the include base paths
- for lwIP itself (${LWIP_DIR}/src/include)
- for lwIP contrib if you use it (${LWIP_DIR}/contrib)
- to a directory containing an OS port
- to a directory containing lwipopts.h
Example:
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/src/include"
"${LWIP_DIR}/contrib"
"${LWIP_DIR}/contrib/ports/unix/port/include"
"${LWIP_DIR}/contrib/examples/example_app"
)
Putting it all together
=======================
To get a working application, your CMake system
needs to provide the variables described above, e.g.
set (LWIP_DIR <path to lwip sources>)
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/src/include"
"${LWIP_DIR}/contrib"
"<path to my port>/include"
"<path to lwipopts.h>"
)
You may add some defines:
set (LWIP_DEFINITIONS LWIP_DEBUG=1)
Then include the filelists you need:
include(${LWIP_DIR}/src/Filelists.cmake)
include(${LWIP_DIR}/contrib/Filelists.cmake)
Then, declare you executable:
add_executable(my_app <my source files> <my lwip port files>)
Add lwIP include dirs to your app:
target_include_directories(my_app PRIVATE ${LWIP_INCLUDE_DIRS})
Link your app against the lwIP libs from the filelists you need:
target_link_libraries(my_app lwipcontribapps lwipallapps lwipcore)
Working example
===============
Working build examples can be found in the
contrib/ports/{win32, unix}/example_app
subdirectory.
To use them, create a build directory and call cmake with
the lwIP root dir:
- mkdir build
- cd build
- cmake ..
- cmake --build .
The CMakeLists.txt will autoselect the correct port
for your system (supported: Linux, Windows, Darwin).
To configure the example app to your needs, you need to copy the file
contrib/examples/example_app/lwipcfg.h.example
to
contrib/examples/example_app/lwipcfg.h
and edit to your needs.
Makefile based build system
===========================
lwIP also maintains file lists for Makefile-based
build systems. Look for Filelists.mk files
in the source tree. We try to maintain them,
but lwIP's mainly focused build system is CMake.
MS Visual Studio
================
lwIP also provides basic support for MSVS in the win32 port
folder under 'msvc'. We try to maintain these files,
but lwIP's mainly focused build system is CMake.

686
CHANGELOG
View File

@@ -1,588 +1,19 @@
HISTORY
* These are only the most important changes. For a full list, use git log:
http://git.savannah.nongnu.org/cgit/lwip.git
(git master)
* [Enter new changes just after this line - do not remove this line]
++ Bugfixes:
2025-06-03: Simon Goldschmidt
* ip4_frag/ip6_frag: fix potential NULL-pointer access on memory errors
(STABLE-2.2.1):
++ New features:
2023-10-11: Faidon Liambotis
* Add MEM_CUSTOM_ALLOCATOR and make LIBC a subset of it
2023-09-29: Jiri Findejs
* mqtt: support binary Will Message
++ Bugfixes:
2024-02-19: Simon Goldschmidt
* tcpip: fix that TCPIP_CORE_LOCK is not released for LWIP_TIMERS==0
2024-01-09: Simon Goldschmidt
* snmp v3, ppp: prevent possible timing attacks by using a constant-runtime-memcmp when
checking credentials
2023-01-04: Simon Goldschmidt
* makefsdata: update tinydir.h to newest version (1.2.6)
2023-10-12: Borys Szefler
* dhcp: fix memory corruption when LWIP_DHCP_MAX_DNS_SERVERS > DNS_MAX_SERVERS
2023-10-11: Mazakazu
* sockets: fix socket leak when using setsockopt/getsockopt hook with LWIP_NETCONN_FULLDUPLEX==1
2023-10-10: Simon Goldschmidt
* sockets: fix bug #63898: allow socket option IPV6_CHECKSUM for both IPPROTO_IPV6 and IPPROTO_RAW
2023-10-10: Simon Goldschmidt
* ipv6: fix ip6_current_header() after reassembly
2023-10-07: Simon Goldschmidt
* ipv6 reassembly: fix detecting holes in reassembled packets
2023-10-04: Simon Goldschmidt
* apps: http client: improve the HTTP client; ensure connection settings are passed
2023-10-03: Simon Goldschmidt
* ipv6: frag: fix bogus icmp6 response on reassembly timeout
2023-09-28: Szabolcs Szekelyi
* httpd: ensure headers are parsed case-insensitive
2023-09-28: Erik Ekman
* Fix ND6 Router Advertisement parsing when NETIF_MAX_HWADDR_LEN is above 6.
2023-09-27: Hardy Griech
* Fix iperf byte counting mode
(STABLE-2.2.0):
2018-10-02: Dirk Ziegelmeier
* Integrate contrib repository into main lwIP repository
++ New features:
2022-04-05: David Cermak
* contrib/addons: Add example of using DHCP extra options hooks
2023-05-11: David Cermak
* dhcp: Add macro for appending extra client's request options
2023-05-11: xueyunfei
* dhcp: Enable custom config for timeouts, thresholds, backoff time
2021-04-26
* test/unit: added more unit tests
2020-03-27: Simon Goldschmidt
* test/fuzz: improve fuzz test
2019-12-11: Simon Goldschmidt
* ip6addr_aton: support scoped address strings (via '%')
2019-08-28: Joan Lledó
* Contrib: Add kFreeBSD to the Unix port
2019-07-14: Joan Lledó
* Unix port: improve support for the Hurd
++ Bugfixes:
2019-12-11: David Girault
* altcp_tls: support for saving/restoring session information
2018-11-16: Craig McQUeen
* dns: allow a DNS look-up with a trailing dot in the name
2018-10-19: Timmy Brolin
* Add outgoing VLAN PCP support for Ethernet level QoS
2018-10-08: Ben Wijen
* apps/tftp: added TFTP client
2018-10-04: Jasper Verschueren
* Implement IPv4 ACD (Address Conflict Detection)
2023-05-10
* altcp_tls_mbedtls: note which version of mbedtls we are compatible to
* altcp_tls_mbedtls: multiple compatibility fixes
2023-04-26: Jan Breuer, Harrold Spier, Ognjen Bjelica, Dirk Ziegelmeier, Simon Goldschmidt
* apps/snmp: multiple fixes and improvements to snmp
2022-01-12: Simon Goldschmidt
* httpd: clean up custom file handling
2021-11-25: quanjia
* ping: fix sockaddr len in ping_send() for PING_USE_SOCKETS==1
2021-11-12: Bas Prins
* http_client: reset timeout when receiving data
2020-07-07: Erik Ekman
* Rename IP and Ethernet equality checkers from _cmp to _eq
2020-03-05: Simon Goldschmidt
* tcp: tighten up checks for received SYN
2020-01-30: Simon Goldschmidt, David Girault, David J. Fiddes, Tom Ferrin
* apps/sntp: multiple fixes and improvements for sntp
2020-01-30: Simon Goldschmidt
* ip_forward: fix IPv4 forwarding with multiple netifs/offloading
2019-06-11: David Girault, Giuseppe Modugno
* apps/mqtt: multiple fixes for mqtt
2019-05-19: Joan Lledó
* New function tcpip_callback_wait()
Call a function inside the tcpip thread and block the calling thread until
the callback finishes
2018-08-15: Jasper Verschueren, David Girault, Our Air Quality
* apps/mdns: greatly improved the mdns client
(STABLE-2.1.2):
++ Bugfixes:
2018-11-21: Jens Nielsen
* netbiosns.c: fix expecting too large packet (bug #55069)
2018-11-19: Dirk Ziegelmeier
* smtp.c: fix compiling with strict C compatibility because of strnlen (bug #55034)
2018-11-12: Simon Goldschmidt
* tcp.c: fix overflow check in tcp_recved triggering invalid assertion (bug #55015)
2018-11-12: Simon Goldschmidt
* tcp.c: fix a bug in sending RST segments (sent from port 0)
(STABLE-2.1.1):
++ Bugfixes:
2018-11-01: Joan Lledó
* sockets.c: fix bad assertion in lwip_poll_dec_sockets_used() (bug #54933)
2018-11-01: Dirk Ziegelmeier
* ip4.c: don't send 127.* to default netif (bug #54670)
2018-10-23: David Girault
* altcp_tls_mbedtls.c: fix use-after free (bug #54774)
2018-10-23: Ognjen Bjelica, Dirk Ziegelmeier
* snmp_scalar.c: Avoid NULL pointer dereference (bug #54886)
2018-10-23: Simon Goldschmidt
* Fix missing standard includes in multiple files
2018-10-17: Ivan Warren
* def.h: fix casting htonX and ntohX to u16_t (bug #54850)
2018-10-12: Simon Goldschmidt
* Revert "tcp_abandon: no need to buffer pcb->local_port" (fix that source port was 0 for RST
called when aborting a connection)
2018-10-11: Jonas Rabenstein
* tcp.c: tcp_recved: check for overflow and warn about too big values (patch #9699)
2018-10-06: Joan Lledó
* sockets.c: alloc_socket(): Check for LWIP_SOCKET_POLL when setting select-
related variables (patch #9696)
2018-10-04: Spencer
* tcp.c: Update prev pointer when skipping entries in tcp_slowtmr (patch #9694)
2018-09-27: Martine Lenders
* lowpan6.c: Fix IEEE 802.15.4 address setting (bug #54749)
(STABLE-2.1.0):
++ New features:
2018-06-17: Simon Goldschmidt
* lwiperf: implemented iPerf client mode
2018-04-23: Dirk Ziegelmeier
* added cmake build files
2018-03-04: Ray Abram
* netbios responder: respond to '*' queries
2018-02-23: Benjamin Aigner
* 6lowpan: add 6lowpan-over-BLE netif (based on existing 6lowpan netif)
2018-02-22: Simon Goldschmidt
* ipv6: add support for stateless DHCPv6 (to get DNS servers in SLAAC nets)
2018-02-16: Simon Goldschmidt
* add raw API http(s) client (with proxy support)
2018-02-01: Simon Goldschmidt
* tcp: add hooks to implement additional socket options
2018-02-01: Simon Goldschmidt
* tcp: add hooks to implement tcp md5 signatures or similar (see contrib/addons for an example)
2018-01-05: Simon Goldschmidt
* Added sys_mbox_trypost_fromisr() and tcpip_callbackmsg_trycallback_fromisr()
These can be used to post preallocated messages from an ISR to the tcpip thread
(e.g. when using FreeRTOS)
2018-01-02: Dirk Ziegelmeier
* task #14780: Add debug helper asserts to ensure threading/locking requirements are met
2017-11-21: Simon Goldschmidt
* task #14600: tcp_alloc(): kill TF_CLOSEPEND connections before other ESTABLISHED
2017-11-21: Simon Goldschmidt
* makefsdata: added option "-ssi:<filename>" to control SSI tag checking/insertion
through a list of filenames, not by checking the file extension at runtime
2017-11-20: Joel Cunningham
* netconn: add LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE to use external DNS resolver (patch #9427)
2017-11-14: Joel Cunningham
* netifapi: Add thread safe ARP cache APIs (task #14724)
2017-11-06: Axel Lin
* TCP: kill existing connections with a LOWER priority than the one currently being opened.
Previous implementations also kill existing connections of the SAME priority.
2017-09-21: Kalle Olavi Niemitalo
* sockets: add poll() implementation (patch #9450)
2017-09-10: Joel Cunningham
* sockets: add readv() implementation (task #14610)
2017-08-04: Simon Goldschmidt
* Clean up DHCP a bit: no need keep msg_out and msg_in as members in struct
dhcp - they are used in a call stack only (p_out and options_out_len as well)
2017-08-04: Simon Goldschmidt
* pbuf: split pbuf_header(s16_t) into pbuf_add_header(size_t) and
pbuf_remove_header(size_t)
2017-07-20: Douglas
* sys: deprecate sys_arch_sem_wait and sys_arch_mbox_fetch returning the
time waited rather they are now defined to return != SYS_ARCH_TIMEOUT
on success.
2017-07-03: Jakub Schmidtke
* tcp: added support for sending TCP SACKs
2017-06-20: Joel Cunningham
* netconn/netdb: added core locking support to netconn_gethostbyname (task #14523)
2017-04-25: Simon Goldschmidt
* dhcp: added two hooks for adding and parsing user defined DHCP options
2017-04-25: Joel Cunningham
* sockets: added recvmsg for UDP (together with CMSG and IP_PKTINFO) (task #14247)
2017-04-20: Joel Cunningham
* tcp: added Appropriate Byte Counting support (task #14128)
2017-04-11: Simon Goldschmidt
* netconn/sockets: remove fatal error handling, fix asynchronous error handling,
ensure data before RST can be received
2017-03-30: Simon Goldschmidt
* added "application layered TCP" connection API (altcp) for seamless integration
of TLS or proxy connections
2017-03-09: Simon Goldschmidt
* sockets: add recvmsg for TCP
2017-03-02: Joel Cunningham
* netconn/sockets: vectorize netconn_write for TCP, treating a vectored I/O write
atomically in regards to TCP segmentation (patch #8882)
2017-03-02: Simon Goldschmidt
* netconn: added nonblocking accept/recv to netconn API (task #14396)
2017-02-28: Simon Goldschmidt
* Added LWIP_SINGLE_NETIF for small targets with only one netif
2017-02-10: David van Moolenbroek
* Implement UDP and RAW multicast support for IPv6 (core API, not netconn/sockets)
2017-02-04: David van Moolenbroek
* IPv6 scopes support
2017-01-20: Joel Cunningham
* sockets: add interface name/index APIs (task #14314)
2017-01-08: David van Moolenbroek
* Extensions to RAW API (patch #9208)
- Connected RAW PCBs
- Add raw_sendto_if_src()
- Support IP_HDRINCL socket option
++ Bugfixes:
2018-06-19: Simon Goldschmidt
* tcp: fix RTO timer not working if link is down
2018-06-15: Sylvain Rochet
* ppp: multiple smaller bugfixes
2018-05-17: Simon Goldschmidt
* etharp: arp table can now be bigger than 127 entries
2018-04-25: Jens Nielsen
* tftp server: correctly handle retransmissions
2018-04-18: Simon Goldschmidt
sockets: fix race conditions when closing full-duplex sockets
2018-03-09: Simon Goldschmidt
* 6lowpan: fix to work against contiki; added ZigBee encapsulation netif for tests
2018-02-04: Simon Goldschmidt
* sockets: fix inconsistencies on close (inconsistent error codes, double FIN)
2018-01-05: Dirk Ziegelmeier
* Fix bug #52748: the bug in timeouts.c by reimplementing timer logic to use
absolute instead of relative timeout values
2017-12-31: Dirk Ziegelmeier
* Fix bug #52704: DHCP and bad OFFER: Stop timeout only if offer is accepted
2017-11-08: Joel Cunningham
* netif: ensure link and admin states are up in issue reports (bug #52353)
2017-09-12: David Lockyer
* select: allocate select_cb from memp for LWIP_MPU_COMPATIBLE = 1 (bug #51990)
2017-09-11: Simon Goldschmidt
* tcp_in.c: fix bug #51937 (leaking tcp_pcbs on passive close with unacked data)
2017-08-11: Joel Cunningham
* lwip_itoa: fix converting the number 0 (previously converted to '\0') (bug #51729)
2017-08-08: Dirk Ziegelmeier
* ip4_route_src: parameter order is reversed: ip4_route_src(dest, src) -> ip4_route_src(src, dest)
to make parameter order consistent with other ip*_route*() functions
Same also applies to LWIP_HOOK_IP4_ROUTE_SRC() parameter order.
2017-08-04: Joel Cunningham
* tcp: re-work persist timer to fully close window (details in bug #50837)
2017-07-26: Simon Goldschmidt
* snmp_msg.c: fix bug #51578 (SNMP failed to decode some values on non 32bit platforms)
2017-07-20: Simon Goldschmidt
* compatibility headers: moved from 'src/include/posix' to 'src/include/compat/posix',
'src/include/compat/stdc' etc.
2017-05-09: Joel Cunningham
* tcp: add zero-window probe timeout (bug #50837)
2017-04-11: Simon Goldschmidt
* sockets.c: task #14420 (Remove sys_sem_signal from inside SYS_ARCH_PROTECT
crit section) done for LWIP_TCPIP_CORE_LOCKING==1
2017-02-24: Simon Goldschmidt
* sockets.c: fixed close race conditions in lwip_select (for LWIP_NETCONN_FULLDUPLEX)
2017-02-24: Simon Goldschmidt
* sockets.c: fixed that select ignored invalid/not open sockets in the fd_sets (bug #50392)
2017-01-11: David van Moolenbroek
* Lots of IPv6 related fixes and improvements
(STABLE-2.0.3)
++ Bugfixes:
2017-09-11: Simon Goldschmidt
* tcp_in.c: fix bug #51937 (leaking tcp_pcbs on passive close with unacked data)
2017-08-02: Abroz Bizjak/Simon Goldschmidt
* multiple fixes in IPv4 reassembly (leading to corrupted datagrams received)
2017-03-30: Simon Goldschmidt
* dhcp.c: return ERR_VAL instead of asserting on offset-out-of-pbuf
2017-03-23: Dirk Ziegelmeier
* dhcp.h: fix bug #50618 (dhcp_remove_struct() macro does not work)
(STABLE-2.0.2)
++ New features:
2017-02-10: Dirk Ziegelmeier
* Implement task #14367: Hooks need a better place to be defined:
We now have a #define for a header file name that is #included in every .c
file that provides hooks.
2017-02-10: Simon Goldschmidt
* tcp_close does not fail on memory error (instead, FIN is sent from tcp_tmr)
++ Bugfixes:
2017-03-08
* tcp: do not keep sending SYNs when getting ACKs
2017-03-08: Joel Cunningham
* tcp: Initialize ssthresh to TCP_SND_BUF (bug #50476)
2017-03-01: Simon Goldschmidt
* httpd: LWIP_HTTPD_POST_MANUAL_WND: fixed double-free when httpd_post_data_recved
is called nested from httpd_post_receive_data() (bug #50424)
2017-02-28: David van Moolenbroek/Simon Goldschmidt
* tcp: fixed bug #50418: LWIP_EVENT_API: fix invalid calbacks for SYN_RCVD pcb
2017-02-17: Simon Goldschmidt
* dns: Improved DNS_LOCAL_HOSTLIST interface (bug #50325)
2017-02-16: Simon Goldschmidt
* LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274)
2017-02-13: Simon Goldschmidt/Dirk Ziegelmeier
* For tiny targtes, LWIP_RAND is optional (fix compile time checks)
2017-02-10: Simon Goldschmidt
* tcp: Fixed bug #47485 (tcp_close() should not fail on memory error) by retrying
to send FIN from tcp_fasttmr
2017-02-09: Simon Goldschmidt
* sockets: Fixed bug #44032 (LWIP_NETCONN_FULLDUPLEX: select might work on
invalid/reused socket) by not allowing to reallocate a socket that has
"select_waiting != 0"
2017-02-09: Simon Goldschmidt
* httpd: Fixed bug #50059 (httpd LWIP_HTTPD_SUPPORT_11_KEEPALIVE vs.
LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED)
2017-02-08: Dirk Ziegelmeier
* Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191:
"IPv4-mapped IPv6 address"
2017-02-08: Luc Revardel
* mld6.c: Fix bug #50220 (mld6_leavegroup does not send ICMP6_TYPE_MLD, even
if last reporter)
2017-02-08: David van Moolenbroek
* ip6.c: Patch #9250: fix source substitution in ip6_output_if()
2017-02-08: Simon Goldschmidt
* tcp_out.c: Fixed bug #50090 (last_unsent->oversize_left can become wrong value
in tcp_write error path)
2017-02-02: Dirk Ziegelmeier
* Fix bug #50206: UDP Netconn bind to IP6_ADDR_ANY fails
2017-01-18: Dirk Ziegelmeier
* Fix zero-copy RX, see bug bug #50064. PBUF_REFs were not supported as ARP requests.
2017-01-15: Axel Lin, Dirk Ziegelmeier
* minor bug fixes in mqtt
2017-01-11: Knut Andre Tidemann
* sockets/netconn: fix broken default ICMPv6 handling of checksums
(STABLE-2.0.1)
++ New features:
2016-12-31: Simon Goldschmidt
* tcp.h/.c: added function tcp_listen_with_backlog_and_err() to get the error
reason when listening fails (bug #49861)
2016-12-20: Erik Andersen
* Add MQTT client
2016-12-14: Jan Breuer:
* opt.h, ndc.h/.c: add support for RDNSS option (as per RFC 6106)
2016-12-14: David van Moolenbroek
* opt.h, nd6.c: Added LWIP_HOOK_ND6_GET_GW()
2016-12-09: Dirk Ziegelmeier
* ip6_frag.c: Implemented support for LWIP_NETIF_TX_SINGLE_PBUF
2016-12-09: Simon Goldschmidt
* dns.c: added one-shot multicast DNS queries
2016-11-24: Ambroz Bizjak, David van Moolenbroek
* tcp_out.c: Optimize passing contiguous nocopy buffers to tcp_write (bug #46290)
2016-11-16: Dirk Ziegelmeier
* sockets.c: added support for IPv6 mapped IPv4 addresses
++ Bugfixes:
2016-12-16: Thomas Mueller
* api_lib.c: fixed race condition in return value of netconn_gethostbyname()
(and thus also lwip_gethostbyname/_r() and lwip_getaddrinfo())
2016-12-15: David van Moolenbroek
* opt.h, tcp: added LWIP_HOOK_TCP_ISN() to implement less predictable initial
sequence numbers (see contrib/addons/tcp_isn for an example implementation)
2016-12-05: Dirk Ziegelmeier
* fixed compiling with IPv4 disabled (IPv6 only case)
2016-11-28: Simon Goldschmidt
* api_lib.c: fixed bug #49725 (send-timeout: netconn_write() can return
ERR_OK without all bytes being written)
2016-11-28: Ambroz Bizjak
* tcpi_in.c: fixed bug #49717 (window size in received SYN and SYN-ACK
assumed scaled)
2016-11-25: Simon Goldschmidt
* dhcp.c: fixed bug #49676 (Possible endless loop when parsing dhcp options)
2016-11-23: Dirk Ziegelmeier
* udp.c: fixed bug #49662: multicast traffic is now only received on a UDP PCB
(and therefore on a UDP socket/netconn) when the PCB is bound to IP_ADDR_ANY
2016-11-16: Dirk Ziegelmeier
* *: Fixed dual-stack behaviour, IPv6 mapped IPv4 support in socket API
2016-11-14: Joel Cunningham
* tcp_out.c: fixed bug #49533 (start persist timer when unsent seg can't fit
in window)
2016-11-16: Roberto Barbieri Carrera
* autoip.c: fixed bug #49610 (sometimes AutoIP fails to reuse the same address)
2016-11-11: Dirk Ziegelmeier
* sockets.c: fixed bug #49578 (dropping multicast membership does not work
with LWIP_SOCKET_OFFSET)
(STABLE-2.0.0)
++ New features:
2016-07-27: Simon Goldschmidt
* opt.h, timeouts.h/.c: added LWIP_TIMERS_CUSTOM to override the default
implementation of timeouts
2016-07-xx: Dirk Ziegelmeier
* Large overhaul of doxygen documentation
2016-04-05: Simon Goldschmidt
2016-04-05: Simon Goldschmidt:
* timers.h/.c: prepare for overriding current timeout implementation: all
stack-internal caclic timers are avaliable in the lwip_cyclic_timers array
2016-03-23: Simon Goldschmidt
* tcp: call accept-callback with ERR_MEM when allocating a pcb fails on
passive open to inform the application about this error
ATTENTION: applications have to handle NULL pcb in accept callback!
ATTENTION: applications have to handle NULL pcb in accept callback!
2016-02-22: Ivan Delamer
* Initial 6LoWPAN support
@@ -830,7 +261,7 @@ HISTORY
implementation which is under a BSD-ish license.
- Also switched to PolarSSL MD4,MD5,SHA1 implementations, which are meant to be
used in embedded devices with reduced memory footprint.
- Removed PPP configuration file parsing support.
- Removed PPP configuration file parsing support.
- Added macro definition EAP_SUPPORT to make EAP support optional.
- Added macro definition CHAP_SUPPORT to make CHAP support optional.
- Added macro definition MSCHAP_SUPPORT to make MSCHAP support optional.
@@ -890,31 +321,6 @@ HISTORY
++ Bugfixes:
2016-08-23: Simon Goldschmidt
* etharp: removed ETHARP_TRUST_IP_MAC since it is insecure and we don't need
it any more after implementing unicast ARP renewal towards arp entry timeout
2016-07-20: Simon Goldschmidt
* memp.h/.c: fixed bug #48442 (memp stats don't work for MEMP_MEM_MALLOC)
2016-07-21: Simon Goldschmidt (patch by Ambroz Bizjak)
* tcp_in.c, tcp_out.c: fixed bug #48543 (TCP sent callback may prematurely
report sent data when only part of a segment is acked) and don't include
SYN/FIN in snd_buf counter
2016-07-19: Simon Goldschmidt
* etharp.c: fixed bug #48477 (ARP input packet might update static entry)
2016-07-11: Simon Goldschmidt
* tcp_in.c: fixed bug #48476 (TCP sent callback called wrongly due to picking
up old pcb->acked
2016-06-30: Simon Goldschmidt (original patch by Fabian Koch)
* tcp_in.c: fixed bug #48170 (Vulnerable to TCP RST spoofing)
2016-05-20: Dirk Ziegelmeier
* sntp.h/.c: Fix return value of sntp_getserver() call to return a pointer
2016-04-05: Simon Goldschmidt (patch by Philip Gladstone)
* udp.c: patch #8358: allow more combinations of listening PCB for IPv6
@@ -1362,7 +768,7 @@ HISTORY
2012-03-25: Simon Goldschmidt (idea by Mason)
* posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h
which are a simple wrapper to the correct lwIP include files.
2012-01-16: Simon Goldschmidt
* opt.h, icmp.c: Added option CHECKSUM_GEN_ICMP
@@ -1444,10 +850,10 @@ HISTORY
2012-03-22: Simon Goldschmidt
* ip4.c: fixed bug #35927: missing refragmentaion in ip_forward
2012-03-20: Simon Goldschmidt (patch by Mason)
* netdb.c: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list
2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic)
* ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian,
possible bug on little endian system
@@ -1902,7 +1308,7 @@ HISTORY
2011-03-27: Simon Goldschmidt
* sockets.c: Fixed bug #32906: lwip_connect+lwip_send did not work for udp and
raw pcbs with LWIP_TCPIP_CORE_LOCKING==1.
2011-03-27: Simon Goldschmidt
* tcp_out.c: Fixed bug #32820 (Outgoing TCP connections created before route
is present never times out) by starting retransmission timer before checking
@@ -1955,7 +1361,7 @@ HISTORY
2010-11-23: Simon Goldschmidt
* tcp_in.c: Fixed bug #30577: tcp_input: don't discard ACK-only packets after
refusing 'refused_data' again.
2010-11-22: Simon Goldschmidt
* sockets.c: Fixed bug #31590: getsockopt(... SO_ERROR ...) gives EINPROGRESS
after a successful nonblocking connection.
@@ -2000,21 +1406,21 @@ HISTORY
2010-08-01: Simon Goldschmidt (patch by Greg Renda)
* ppp.c: Applied patch #7264 (PPP protocols are rejected incorrectly on big
endian architectures)
2010-07-28: Simon Goldschmidt
* api_lib.c, api_msg.c, sockets.c, mib2.c: Fixed compilation with TCP or UDP
disabled.
2010-07-27: Simon Goldschmidt
* tcp.c: Fixed bug #30565 (tcp_connect() check bound list): that check did no
harm but never did anything
2010-07-21: Simon Goldschmidt
* ip.c: Fixed invalid fix for bug #30402 (CHECKSUM_GEN_IP_INLINE does not
add IP options)
2010-07-16: Kieran Mansley
* msg_in.c: Fixed SNMP ASN constant defines to not use ! operator
* msg_in.c: Fixed SNMP ASN constant defines to not use ! operator
2010-07-10: Simon Goldschmidt
* ip.c: Fixed bug #30402: CHECKSUM_GEN_IP_INLINE does not add IP options
@@ -2118,7 +1524,7 @@ HISTORY
2010-03-05: Simon Goldschmidt
* api_msg.c: Correctly set TCP_WRITE_FLAG_MORE when netconn_write is split
into multiple calls to tcp_write.
into multiple calls to tcp_write.
2010-02-21: Simon Goldschmidt
* opt.h, mem.h, dns.c: task #10140: Remove DNS_USES_STATIC_BUF (keep
@@ -2578,7 +1984,7 @@ HISTORY
sent to mbox
2009-06-25 Kieran Mansley
* api_msg.c api.h: BUG26722: initialise netconn write variables
* api_msg.c api.h: BUG26722: initialise netconn write variables
in netconn_alloc
2009-06-25 Kieran Mansley
@@ -2586,7 +1992,7 @@ HISTORY
2009-06-25 Kieran Mansley
* tcp.c, tcp_in.c, tcp_out.c, tcp.h: BUG26301 and BUG26267: correct
simultaneous close behaviour, and make snd_nxt have the same meaning
simultaneous close behaviour, and make snd_nxt have the same meaning
as in the RFCs.
2009-05-12 Simon Goldschmidt
@@ -2722,7 +2128,7 @@ HISTORY
* tcp.c, tcp_in.c, tcp.h: add tcp_abandon() to cope with dropping
connections where no reset required (bug #25622)
* tcp_out.c: set TCP_ACK flag on keepalive and zero window probes
* tcp_out.c: set TCP_ACK flag on keepalive and zero window probes
(bug #20779)
2009-02-18 Simon Goldschmidt (Jonathan Larmour and Bill Auerbach)
@@ -2758,7 +2164,7 @@ HISTORY
out of pool pbufs.
2008-12-19 Simon Goldschmidt
* many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2
* many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2
2008-12-10 Tamas Somogyi, Frédéric Bernon
* sockets.c: fixed bug #25051: lwip_recvfrom problem with udp: fromaddr and
@@ -2843,7 +2249,7 @@ HISTORY
made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM.
2008-01-22 Frédéric Bernon
* tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in
* tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in
TCP_CALCULATE_EFF_SEND_MSS to have coherent TCP options names.
2008-01-14 Frédéric Bernon
@@ -2853,7 +2259,7 @@ HISTORY
2008-01-14 Frédéric Bernon, Marc Chaland
* ip.c: Integrate patch #6369" ip_input : checking before realloc".
2008-01-12 Frédéric Bernon
* tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field
netconn::sem per netconn::op_completed like suggested for the task #7490
@@ -2879,8 +2285,8 @@ HISTORY
Introduce changes for task #7490 "Add return value to sys_mbox_post" with some
modifications in the sys_mbox api: sys_mbox_new take a "size" parameters which
indicate the number of pointers query by the mailbox. There is three defines
in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the
netconn::acceptmbox. Port maintainers, you can decide to just add this new
in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the
netconn::acceptmbox. Port maintainers, you can decide to just add this new
parameter in your implementation, but to ignore it to keep the previous behavior.
The new sys_mbox_trypost function return a value to know if the mailbox is
full or if the message is posted. Take a look to sys_arch.txt for more details.
@@ -3004,7 +2410,7 @@ HISTORY
Note that previous "copy" parameter for "write" APIs is now called "apiflags".
2007-10-24 Frédéric Bernon
* api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than
* api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than
TCP_EVENT_xxx macros to get a code more readable. It could also help to remove
some code (like we have talk in "patch #5919 : Create compile switch to remove
select code"), but it could be done later.
@@ -3024,7 +2430,7 @@ HISTORY
all netifs (or ports) can use it.
2007-10-05 Frédéric Bernon
* netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the
* netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the
common function to reduce a little bit the footprint (for all functions using
only the "netif" parameter).
@@ -3048,7 +2454,7 @@ HISTORY
or snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro.
This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside
snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only
when it's queried (any direct call to "sysuptime" is changed by a call to
when it's queried (any direct call to "sysuptime" is changed by a call to
snmp_get_sysuptime).
2007-09-09 Frédéric Bernon, Bill Florac
@@ -3129,7 +2535,7 @@ HISTORY
2007-08-26 Marc Boucher
* api_msg.c: do_close_internal(): Reset the callbacks and arg (conn) to NULL
since they can under certain circumstances be called with an invalid conn
pointer after the connection has been closed (and conn has been freed).
pointer after the connection has been closed (and conn has been freed).
2007-08-25 Frédéric Bernon (Artem Migaev's Patch)
* netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up".
@@ -3141,11 +2547,11 @@ HISTORY
2007-08-22 Frédéric Bernon
* tcpip.h, tcpip.c, ethernetif.c, opt.h: remove options ETHARP_TCPIP_INPUT &
ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the
ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the
name is tcpip_input (we keep the name of 1.2.0 function).
2007-08-17 Jared Grubb
* memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool
* memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool
settings into new memp_std.h and optional user file lwippools.h. This adds
more dynamic mempools, and allows the user to create an arbitrary number of
mempools for mem_malloc.
@@ -3352,32 +2758,32 @@ HISTORY
snmp_set_sysname.
2007-03-28 Frédéric Bernon
* netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to
* netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to
initialize a network interface's flag with. It tell this interface is an ethernet
device, and we can use ARP with it to do a "gratuitous ARP" (RFC 3220 "IP Mobility
Support for IPv4" section 4.6) when interface is "up" with netif_set_up().
2007-03-26 Frédéric Bernon, Jonathan Larmour
* opt.h, tcpip.c: New configuration option LWIP_ARP allow to disable ARP init at build
time if you only use PPP or SLIP. The default is enable. Note we don't have to call
time if you only use PPP or SLIP. The default is enable. Note we don't have to call
etharp_init in your port's initilization sequence if you use tcpip.c, because this call
is done in tcpip_init function.
2007-03-22 Frédéric Bernon
* stats.h, stats.c, msg_in.c: Stats counters can be change to u32_t if necessary with the
new option LWIP_STATS_LARGE. If you need this option, define LWIP_STATS_LARGE to 1 in
your lwipopts.h. More, unused counters are not defined in the stats structs, and not
your lwipopts.h. More, unused counters are not defined in the stats structs, and not
display by stats_display(). Note that some options (SYS_STATS and RAW_STATS) are defined
but never used. Fix msg_in.c with the correct #if test for a stat display.
2007-03-21 Kieran Mansley
* netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com).
* netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com).
Provides callback on netif up/down state change.
2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds
* sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c,
ip.c, netif.h, tcpip.c, opt.h:
New configuration option LWIP_IGMP to enable IGMP processing. Based on only one
New configuration option LWIP_IGMP to enable IGMP processing. Based on only one
filter per all network interfaces. Declare a new function in netif to enable to
control the MAC filter (to reduce lwIP traffic processing).
@@ -3400,7 +2806,7 @@ HISTORY
* snmp_msg.h, msg_in.c: SNMP UDP ports can be configured at compile time.
2007-03-06 Frédéric Bernon
* api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h:
* api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h:
Implement SO_RCVTIMEO on UDP sockets/netconn.
2007-02-28 Kieran Mansley (based on patch from Simon Goldschmidt)
@@ -3442,7 +2848,7 @@ HISTORY
and/or warnings on some systems where mem_size_t and size_t differ.
* pbuf.c, ppp.c: Fix warnings on some systems with mem_malloc.
2008-03-04 Kieran Mansley (contributions by others)
2008-03-04 Kieran Mansley (contributions by others)
* Numerous small compiler error/warning fixes from contributions to
mailing list after 1.3.0 release candidate made.
@@ -3559,7 +2965,7 @@ HISTORY
type change. Any compiler should cause an error without any changes in
yours netconn_peer calls (so, it can't be a "silent change"). It also
reduce a little bit the footprint for socket layer (lwip_getpeername &
lwip_getsockname use now a common lwip_getaddrname function since
lwip_getsockname use now a common lwip_getaddrname function since
netconn_peer & netconn_addr have the same parameters).
2007-09-20 Simon Goldschmidt
@@ -3579,13 +2985,13 @@ HISTORY
if they are not defined in cc.h, in the same spirit than "lwip/opt.h" for lwipopts.h.
2007-08-30 Frédéric Bernon
* igmp.h, igmp.c: Some changes to remove some redundant code, add some traces,
* igmp.h, igmp.c: Some changes to remove some redundant code, add some traces,
and fix some coding style.
2007-08-28 Frédéric Bernon
* tcpip.c: Fix TCPIP_MSG_INPKT processing: now, tcpip_input can be used for any
kind of packets. These packets are considered like Ethernet packets (payload
pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets
kind of packets. These packets are considered like Ethernet packets (payload
pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets
are considered like IP packets (payload pointing to iphdr).
2007-08-27 Frédéric Bernon
@@ -3683,7 +3089,7 @@ HISTORY
2007-06-28 Frédéric Bernon
* netifapi.h, netifapi.c, tcpip.h, tcpip.c: Update code to handle the option
LWIP_TCPIP_CORE_LOCKING, and do some changes to be coherent with last modifications
in api_lib/api_msg (use pointers and not type with table, etc...)
in api_lib/api_msg (use pointers and not type with table, etc...)
2007-06-26 Simon Goldschmidt
* udp.h: Fixed bug #20259: struct udp_hdr was lacking the packin defines.
@@ -3785,7 +3191,7 @@ HISTORY
2007-05-16 Frédéric Bernon
* tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work
with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in
with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in
tcpip_init) because we have to be sure that network interfaces are already
added (mac filter is updated only in igmp_init for the moment).
@@ -3932,7 +3338,7 @@ HISTORY
2007-03-20 Frédéric Bernon
* tcpip.c: Initialize tcpip's mbox, and verify if initialized in tcpip_input,
tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with
tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with
network interfaces. Also fix a compiler warning.
2007-03-20 Kieran Mansley
@@ -4024,13 +3430,13 @@ HISTORY
* rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call
interval.
2007-02-28 Kieran Mansley
2007-02-28 Kieran Mansley
* pbuf.c: Fix BUG#17645 - ensure pbuf payload pointer is not moved
outside the region of the pbuf by pbuf_header()
2007-02-28 Kieran Mansley
2007-02-28 Kieran Mansley
* sockets.c: Fix BUG#19161 - ensure milliseconds timeout is non-zero
when supplied timeout is also non-zero
when supplied timeout is also non-zero
(STABLE-1.2.0)
@@ -4114,7 +3520,7 @@ HISTORY
in accept() by Kevin Lawson.
2006-05-26 Christiaan Simons
* api_lib.c: Removed conn->sem creation and destruction
* api_lib.c: Removed conn->sem creation and destruction
from netconn_write() and added sys_sem_new to netconn_new_*.
(STABLE-1_1_1)
@@ -4184,7 +3590,7 @@ HISTORY
* dhcp.c: Decline messages were not multicast but unicast.
* etharp.c: ETHARP_CREATE is renamed to ETHARP_TRY_HARD.
Do not try hard to insert arbitrary packet's source address,
etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD.
etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD.
etharp_query() now always DOES call ETHARP_TRY_HARD so that users
querying an address will see it appear in the cache (DHCP could
suffer from this when a server invalidly gave an in-use address.)

View File

@@ -1,37 +0,0 @@
cmake_minimum_required(VERSION 3.10)
set (CMAKE_CONFIGURATION_TYPES "Debug;Release")
project(lwIP)
# Example lwIP application
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set (LWIP_DEFINITIONS LWIP_DEBUG=1)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
add_subdirectory(${LWIP_DIR}/contrib/ports/win32/example_app)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
add_subdirectory(${LWIP_DIR}/contrib/ports/unix/example_app)
else()
message(WARNING "Host ${CMAKE_SYSTEM_NAME} is not supported to build example_app")
endif()
# Source package generation
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack")
set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LWIP_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LWIP_VERSION_REVISION}")
set(CPACK_SOURCE_IGNORE_FILES "/build/;${CPACK_SOURCE_IGNORE_FILES};.git")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "lwip-${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}")
include(CPack)
# Generate docs before creating source package
include(src/Filelists.cmake)
if (NOT TARGET dist)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
if (TARGET lwipdocs)
add_dependencies(dist lwipdocs)
endif()
endif()

54
COPYING
View File

@@ -1,25 +1,33 @@
Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
All rights reserved.
/*
* Copyright (c) 2001, 2002 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>
*
*/
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.

View File

@@ -1,11 +0,0 @@
lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems.
The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM.
Main features include:
- Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0)
- DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), ACD (Address Conflict Detection), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler)
- APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API
- Extended features: IP forwarding over multiple network interfaces
- Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0)
- Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart

2
FILES
View File

@@ -1,6 +1,4 @@
contrib/ - lwIP examples, ports, and small apps (formerly http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git/)
src/ - The source code for the lwIP TCP/IP stack.
doc/ - The documentation for lwIP.
test/ - Some code to test whether the sources do what they should.
See also the FILES file in each subdirectory.

91
README
View File

@@ -1,57 +1,37 @@
INTRODUCTION
lwIP is a small independent implementation of the TCP/IP protocol suite.
lwIP is a small independent implementation of the TCP/IP protocol
suite that has been developed by Adam Dunkels at the Computer and
Networks Architectures (CNA) lab at the Swedish Institute of Computer
Science (SICS).
The focus of the lwIP TCP/IP implementation is to reduce the RAM usage
while still having a full scale TCP. This making lwIP suitable for use
in embedded systems with tens of kilobytes of free RAM and room for
around 40 kilobytes of code ROM.
lwIP was originally developed by Adam Dunkels at the Computer and Networks
Architectures (CNA) lab at the Swedish Institute of Computer Science (SICS)
and is now developed and maintained by a worldwide network of developers.
FEATURES
* IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over
multiple network interfaces
* IP (Internet Protocol) including packet forwarding over multiple network
interfaces
* ICMP (Internet Control Message Protocol) for network maintenance and debugging
* IGMP (Internet Group Management Protocol) for multicast traffic management
* MLD (Multicast listener discovery for IPv6). Aims to be compliant with
RFC 2710. No support for MLDv2
* ND (Neighbor discovery and stateless address autoconfiguration for IPv6).
Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
(Address autoconfiguration)
* DHCP, AutoIP/APIPA (Zeroconf), ACD (Address Conflict Detection)
and (stateless) DHCPv6
* UDP (User Datagram Protocol) including experimental UDP-lite extensions
* TCP (Transmission Control Protocol) with congestion control, RTT estimation
fast recovery/fast retransmit and sending SACKs
* raw/native API for enhanced performance
and fast recovery/fast retransmit
* Specialized raw/native API for enhanced performance
* Optional Berkeley-like socket API
* TLS: optional layered TCP ("altcp") for nearly transparent TLS for any
TCP-based protocol (ported to mbedTLS) (see changelog for more info)
* PPPoS and PPPoE (Point-to-point protocol over Serial/Ethernet)
* DNS (Domain name resolver incl. mDNS)
* 6LoWPAN (via IEEE 802.15.4, BLE or ZEP)
APPLICATIONS
* HTTP server with SSI and CGI (HTTPS via altcp)
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol), v3 via altcp
* SNTP (Simple network time protocol)
* NetBIOS name service responder
* MDNS (Multicast DNS) responder
* iPerf server implementation
* MQTT client (TLS support via altcp)
* DNS (Domain names resolver)
* SNMP (Simple Network Management Protocol)
* DHCP (Dynamic Host Configuration Protocol)
* AUTOIP (for IPv4, conform with RFC 3927)
* PPP (Point-to-Point Protocol)
* ARP (Address Resolution Protocol) for Ethernet
LICENSE
lwIP is freely available under a BSD license.
DEVELOPMENT
lwIP has grown into an excellent TCP/IP stack for embedded devices,
@@ -64,42 +44,38 @@ help improve lwIP by use of Savannah's interface, Git and the
mailing list. A core team of developers will commit changes to the
Git source tree.
The lwIP TCP/IP stack is maintained in the 'src' directory and
contributions (such as platform ports and applications) are in
the 'contrib' directory.
The lwIP TCP/IP stack is maintained in the 'lwip' Git module and
contributions (such as platform ports) are in the 'contrib' Git module.
See doc/savannah.txt for details on Git server access for users and
developers.
The current Git tree is web-browsable:
https://git.savannah.gnu.org/cgit/lwip.git
The current Git trees are web-browsable:
http://git.savannah.gnu.org/cgit/lwip.git
http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git
Submit patches and bugs via the lwIP project page:
https://savannah.nongnu.org/projects/lwip/
Continuous integration builds (GCC, clang):
https://github.com/lwip-tcpip/lwip/actions
http://savannah.nongnu.org/projects/lwip/
DOCUMENTATION
Self documentation of the source code is regularly extracted from the current
Git sources and is available from this web page:
https://www.nongnu.org/lwip/
The original out-dated homepage of lwIP and Adam Dunkels' papers on
lwIP are at the official lwIP home page:
http://www.sics.se/~adam/lwip/
Self documentation of the source code is regularly extracted from the
current Git sources and is available from this web page:
http://www.nongnu.org/lwip/
There is now a constantly growin wiki about lwIP at
http://lwip.wikia.com/wiki/LwIP_Wiki
Also, there are mailing lists you can subscribe at
https://savannah.nongnu.org/mail/?group=lwip
http://savannah.nongnu.org/mail/?group=lwip
plus searchable archives:
https://lists.nongnu.org/archive/html/lwip-users/
https://lists.nongnu.org/archive/html/lwip-devel/
There is a wiki about lwIP at
https://lwip.wikia.com/wiki/LwIP_Wiki
You might get questions answered there, but unfortunately, it is not as
well maintained as it should be.
lwIP was originally written by Adam Dunkels:
http://dunkels.com/adam/
http://lists.nongnu.org/archive/html/lwip-users/
http://lists.nongnu.org/archive/html/lwip-devel/
Reading Adam's papers, the files in docs/, browsing the source code
documentation and browsing the mailing list archives is a good way to
@@ -107,3 +83,4 @@ become familiar with the design of lwIP.
Adam Dunkels <adam@sics.se>
Leon Woestenberg <leon.woestenberg@gmx.net>

143
UPGRADING
View File

@@ -7,149 +7,8 @@ with newer versions.
(git master)
* [Enter new changes just after this line - do not remove this line]
* The eth_addr_cmp and ip_addr_cmp set of functions have been renamed to eth_addr_eq, ip_addr_eq
and so on, since they return non-zero on equality. Macros for the old names exist.
* The sio_write function used by PPP now takes the data argument as const.
* The prev field in the snmp_varbind struct has been removed.
(2.2.0)
++ Repository changes:
* The contrib repository has been added into the main repository in the subdirectory 'contrib'
(the old contrib repository remains online for reference but is not used any more)
(2.1.0)
++ Application changes:
* Use the new altcp API for seamless TLS integration into existing TCP applications (see changelog)
* TCP only kills existing connections with a LOWER priority than the one currently being opened.
Previous implementations also kill existing connections of the SAME priority.
* ip4_route_src: parameter order is reversed: ip4_route_src(dest, src) -> ip4_route_src(src, dest)
to make parameter order consistent with other ip*_route*() functions.
Same also applies to LWIP_HOOK_IP4_ROUTE_SRC() parameter order.
* pbuf API: pbuf->type (an u8_t holding the enum 'pbuf_type') has changed to only hold a
description of the pbuf (e.g. data following pbuf struct, data volatile, allocation
source heap/pool/etc.). As a consequence, applications can't test pbuf->type any more.
Use pbuf_match_type(pbuf, type) instead.
* socket API: according to the standard, SO_ERROR now only returns asynchronous errors.
All other/normal/synchronous errors are (and always were) available via 'errno'.
LWIP_SOCKET_SET_ERRNO has been removed - 'errno' is always set - and required!
* httpd LWIP_HTTPD_CGI_SSI: httpd_cgi_handler() has an additional parameter "struct fs_file *"
++ Port changes:
* tcpip_trycallback() was renamed to tcpip_callbackmsg_trycallback() to avoid confusion
with tcpip_try_callback()
* compatibility headers: moved from 'src/include/posix' to 'src/include/compat/posix',
'src/include/compat/stdc' etc.
* The IPv6 implementation now supports address scopes. (See LWIP_IPV6_SCOPES documentation
and ip6_zone.h for more documentation)
* LWIP_HOOK_DHCP_APPEND_OPTIONS() has changed, see description in opt.h (options_out_len is not
available in struct dhcp any more)
* Added debug helper asserts to ensure threading/locking requirements are met (define
LWIP_MARK_TCPIP_THREAD() and LWIP_ASSERT_CORE_LOCKED()).
* Added sys_mbox_trypost_fromisr() and tcpip_callbackmsg_trycallback_fromisr()
These can be used to post preallocated messages from an ISR to the tcpip thread
(e.g. when using FreeRTOS)
(2.0.2)
++ Application changes:
* slipif: The way to pass serial port number has changed. netif->num is not
supported any more, netif->state is interpreted as an u8_t port number now
(it's not a POINTER to an u8_t any more!)
(2.0.1)
++ Application changes:
* UDP does NOT receive multicast traffic from ALL netifs on an UDP PCB bound to a specific
netif any more. Users need to bind to IP_ADDR_ANY to receive multicast traffic and compare
ip_current_netif() to the desired netif for every packet.
See bug #49662 for an explanation.
(2.0.0)
++ Application changes:
* Changed netif "up" flag handling to be an administrative flag (as opposed to the previous meaning of
"ip4-address-valid", a netif will now not be used for transmission if not up) -> even a DHCP netif
has to be set "up" before starting the DHCP client
* Added IPv6 support (dual-stack or IPv4/IPv6 only)
* Changed ip_addr_t to be a union in dual-stack mode (use ip4_addr_t where referring to IPv4 only).
* Major rewrite of SNMP (added MIB parser that creates code stubs for custom MIBs);
supports SNMPv2c (experimental v3 support)
* Moved some core applications from contrib repository to src/apps (and include/lwip/apps)
+++ Raw API:
* Changed TCP listen backlog: removed tcp_accepted(), added the function pair tcp_backlog_delayed()/
tcp_backlog_accepted() to explicitly delay backlog handling on a connection pcb
+++ Socket API:
* Added an implementation for posix sendmsg()
* Added LWIP_FIONREAD_LINUXMODE that makes ioctl/FIONREAD return the size of the next pending datagram
++ Port changes
+++ new files:
* MANY new and moved files!
* Added src/Filelists.mk for use in Makefile projects
* Continued moving stack-internal parts from abc.h to abc_priv.h in sub-folder "priv"
to let abc.h only contain the actual application programmer's API
+++ sys layer:
* Made LWIP_TCPIP_CORE_LOCKING==1 the default as it usually performs better than
the traditional message passing (although with LWIP_COMPAT_MUTEX you are still
open to priority inversion, so this is not recommended any more)
* Added LWIP_NETCONN_SEM_PER_THREAD to use one "op_completed" semaphore per thread
instead of using one per netconn (these semaphores are used even with core locking
enabled as some longer lasting functions like big writes still need to delay)
* Added generalized abstraction for itoa(), strnicmp(), stricmp() and strnstr()
in def.h (to be overridden in cc.h) instead of config
options for netbiosns, httpd, dns, etc. ...
* New abstraction for hton* and ntoh* functions in def.h.
To override them, use the following in cc.h:
#define lwip_htons(x) <your_htons>
#define lwip_htonl(x) <your_htonl>
+++ new options:
* TODO
+++ new pools:
* Added LWIP_MEMPOOL_* (declare/init/alloc/free) to declare private memp pools
that share memp.c code but do not have to be made global via lwippools.h
* Added pools for IPv6, MPU_COMPATIBLE, dns-api, netif-api, etc.
* added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when a memp pool was empty and an item
is now available
* Signature of LWIP_HOOK_VLAN_SET macro was changed
* LWIP_DECLARE_MEMORY_ALIGNED() may be used to declare aligned memory buffers (mem/memp)
or to move buffers to dedicated memory using compiler attributes
* Standard C headers are used to define sized types and printf formatters
(disable by setting LWIP_NO_STDINT_H=1 or LWIP_NO_INTTYPES_H=1 if your compiler
does not support these)
++ Major bugfixes/improvements
* Added IPv6 support (dual-stack or IPv4/IPv6 only)
* Major rewrite of PPP (incl. keep-up with apache pppd)
see doc/ppp.txt for an upgrading how-to
* Major rewrite of SNMP (incl. MIB parser)
* Fixed timing issues that might have lead to losing a DHCP lease
* Made rx processing path more robust against crafted errors
* TCP window scaling support
* modification of api modules to support FreeRTOS-MPU (don't pass stack-pointers to other threads)
* made DNS client more robust
* support PBUF_REF for RX packets
* LWIP_NETCONN_FULLDUPLEX allows netconn/sockets to be used for reading/writing from separate
threads each (needs LWIP_NETCONN_SEM_PER_THREAD)
* Moved and reordered stats (mainly memp/mib2)
* TODO
(1.4.0)

View File

@@ -1,26 +0,0 @@
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
# Copyright 2020 Jonathan Demeyer <jona.dem@gmail.com>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
changed_files() {
: ${FILEREGEX:='\.([CcHh])$'}
: ${EXCLUDE:=''}
: ${DIFFFILTER:='ACMR'}
DIFFFILTER="--diff-filter=${DIFFFILTER}"
# select either all or only touched-in-branch files, filter through FILEREGEX
if [ -z "${BASE_BRANCH}" ]; then
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
else
FILES="$(git diff ${DIFFFILTER} --name-only ${BASE_BRANCH} | grep -E ${FILEREGEX})"
fi
# filter out negatives
echo "${FILES}" | grep -v -E ${EXCLUDE}
}

View File

@@ -1,59 +0,0 @@
#!/usr/bin/env bash
# Copyright 2019 Alexandre Abadie <alexandre.abadie@inria.fr>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
CODESPELL_CMD="codespell"
if tput colors &> /dev/null && [ "$(tput colors)" -ge 8 ]; then
CERROR=$'\033[1;31m'
CRESET=$'\033[0m'
else
CERROR=
CRESET=
fi
: "${LWIPBASE:=$(cd $(dirname $0)/; pwd)}"
cd $LWIPBASE
: "${LWIPTOOLS:=${LWIPBASE}}"
. "${LWIPTOOLS}"/codespell_changed_files.sh
FILEREGEX='\.([CcHh]|sh|py|md|txt)$'
EXCLUDE='^(./contrib/apps/LwipMibCompiler/Mibs)'
FILES=$(FILEREGEX=${FILEREGEX} EXCLUDE=${EXCLUDE} changed_files)
if [ -z "${FILES}" ]; then
exit 0
fi
${CODESPELL_CMD} --version &> /dev/null || {
printf "%s%s: cannot execute \"%s\"!%s\n" "${CERROR}" "$0" "${CODESPELL_CMD}" "${CRESET}"
exit 1
}
CODESPELL_OPTS="-q 2" # Disable "WARNING: Binary file"
CODESPELL_OPTS+=" --check-hidden"
# Disable false positives "nd => and, 2nd", "ans => and", "tolen => token",
# "ofo => of", "WAN => WANT", "mut => must, mutt, moot"
CODESPELL_OPTS+=" --ignore-words-list=nd,ans,tolen,ofo,wan,mut,clen,useg,clos "
CODESPELL_OPTS+=" --ignore-words-list=devine,clinet,linz,garantie,explicite,numer "
CODESPELL_OPTS+=" --ignore-words-list=skool "
# propagate all options to codespell -> pass "-w" to this script to write changes
CODESPELL_OPTS+="$@"
# Filter-out all false positive raising "disabled due to" messages.
ERRORS=$(${CODESPELL_CMD} ${CODESPELL_OPTS} ${FILES} | grep -ve "disabled due to")
if [ -n "${ERRORS}" ]
then
printf "%sThere are typos in the following files:%s\n\n" "${CERROR}" "${CRESET}"
printf "%s\n" "${ERRORS}"
# TODO: return 1 when all typos are fixed
exit 0
else
exit 0
fi

View File

@@ -1,106 +0,0 @@
typedef unsigned char err_t;
typedef unsigned int u32_t;
typedef unsigned short u16_t;
typedef unsigned char u8_t;
typedef void sys_sem_t;
typedef void sys_mutex_t;
typedef size_t mem_size_t;
typedef size_t memp_t;
struct pbuf;
struct netif;
void* mem_malloc(mem_size_t size)
{
__coverity_alloc__(size);
}
void mem_free(void* mem)
{
__coverity_free__(mem);
}
void* memp_malloc(memp_t type)
{
__coverity_alloc_nosize__();
}
void memp_free(memp_t type, void* mem)
{
__coverity_free__(mem);
}
void sys_mutex_lock(sys_mutex_t* mutex)
{
__coverity_exclusive_lock_acquire__(mutex);
}
void sys_mutex_unlock(sys_mutex_t* mutex)
{
__coverity_exclusive_lock_release__(mutex);
}
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
__coverity_recursive_lock_acquire__(sem);
}
void sys_sem_signal(sys_sem_t *sem)
{
__coverity_recursive_lock_release__(sem);
}
err_t ethernet_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t tcpip_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t ip_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t ip4_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t ip6_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
{
__coverity_tainted_string_argument__(buf);
__coverity_tainted_data_argument__(buf);
}
err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
{
__coverity_tainted_string_argument__(buf);
__coverity_tainted_data_argument__(buf);
}
err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
{
__coverity_tainted_data_transitive__(p_to, p_from);
}
u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset)
{
__coverity_tainted_string_argument__(dataptr);
__coverity_tainted_data_argument__(dataptr);
}
u8_t pbuf_get_at(struct pbuf* p, u16_t offset)
{
__coverity_tainted_data_return__();
}
void abort(void)
{
__coverity_panic__();
}
int check_path(char* path, size_t size)
{
if (size) {
__coverity_tainted_data_sanitize__(path);
return 1;
} else {
return 0;
}
}

View File

@@ -1,61 +0,0 @@
# This file is indended to be included in end-user CMakeLists.txt
# include(/path/to/Filelists.cmake)
# It assumes the variable LWIP_CONTRIB_DIR is defined pointing to the
# root path of lwIP/contrib sources.
#
# This file is NOT designed (on purpose) to be used as cmake
# subdir via add_subdirectory()
# The intention is to provide greater flexibility to users to
# create their own targets using the *_SRCS variables.
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
include_guard(GLOBAL)
endif()
set(lwipcontribexamples_SRCS
${LWIP_CONTRIB_DIR}/examples/httpd/fs_example/fs_example.c
${LWIP_CONTRIB_DIR}/examples/httpd/https_example/https_example.c
${LWIP_CONTRIB_DIR}/examples/httpd/ssi_example/ssi_example.c
${LWIP_CONTRIB_DIR}/examples/lwiperf/lwiperf_example.c
${LWIP_CONTRIB_DIR}/examples/mdns/mdns_example.c
${LWIP_CONTRIB_DIR}/examples/mqtt/mqtt_example.c
${LWIP_CONTRIB_DIR}/examples/ppp/pppos_example.c
${LWIP_CONTRIB_DIR}/examples/snmp/snmp_private_mib/lwip_prvmib.c
${LWIP_CONTRIB_DIR}/examples/snmp/snmp_v3/snmpv3_dummy.c
${LWIP_CONTRIB_DIR}/examples/snmp/snmp_example.c
${LWIP_CONTRIB_DIR}/examples/sntp/sntp_example.c
${LWIP_CONTRIB_DIR}/examples/tftp/tftp_example.c
)
add_library(lwipcontribexamples EXCLUDE_FROM_ALL ${lwipcontribexamples_SRCS})
target_compile_options(lwipcontribexamples PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipcontribexamples PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipcontribexamples PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
set(lwipcontribapps_SRCS
${LWIP_CONTRIB_DIR}/apps/httpserver/httpserver-netconn.c
${LWIP_CONTRIB_DIR}/apps/chargen/chargen.c
${LWIP_CONTRIB_DIR}/apps/udpecho/udpecho.c
${LWIP_CONTRIB_DIR}/apps/tcpecho/tcpecho.c
${LWIP_CONTRIB_DIR}/apps/shell/shell.c
${LWIP_CONTRIB_DIR}/apps/udpecho_raw/udpecho_raw.c
${LWIP_CONTRIB_DIR}/apps/tcpecho_raw/tcpecho_raw.c
${LWIP_CONTRIB_DIR}/apps/netio/netio.c
${LWIP_CONTRIB_DIR}/apps/ping/ping.c
${LWIP_CONTRIB_DIR}/apps/socket_examples/socket_examples.c
${LWIP_CONTRIB_DIR}/apps/rtp/rtp.c
)
add_library(lwipcontribapps EXCLUDE_FROM_ALL ${lwipcontribapps_SRCS})
target_compile_options(lwipcontribapps PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipcontribapps PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipcontribapps PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
set(lwipcontribaddons_SRCS
${LWIP_CONTRIB_DIR}/addons/tcp_isn/tcp_isn.c
${LWIP_CONTRIB_DIR}/addons/ipv6_static_routing/ip6_route_table.c
# ${LWIP_CONTRIB_DIR}/addons/netconn/external_resolve/dnssd.c
# ${LWIP_CONTRIB_DIR}/addons/tcp_md5/tcp_md5.c
)
add_library(lwipcontribaddons EXCLUDE_FROM_ALL ${lwipcontribaddons_SRCS})
target_compile_options(lwipcontribaddons PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipcontribaddons PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipcontribaddons PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})

View File

@@ -1,57 +0,0 @@
#
# Copyright (c) 2001, 2002 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>
#
# CONTRIBAPPFILES: Contrib Applications.
CONTRIBAPPFILES=$(CONTRIBDIR)/apps/httpserver/httpserver-netconn.c \
$(CONTRIBDIR)/apps/chargen/chargen.c \
$(CONTRIBDIR)/apps/udpecho/udpecho.c \
$(CONTRIBDIR)/apps/tcpecho/tcpecho.c \
$(CONTRIBDIR)/apps/shell/shell.c \
$(CONTRIBDIR)/apps/udpecho_raw/udpecho_raw.c \
$(CONTRIBDIR)/apps/tcpecho_raw/tcpecho_raw.c \
$(CONTRIBDIR)/apps/netio/netio.c \
$(CONTRIBDIR)/apps/ping/ping.c \
$(CONTRIBDIR)/apps/socket_examples/socket_examples.c \
$(CONTRIBDIR)/apps/rtp/rtp.c \
$(CONTRIBDIR)/examples/httpd/fs_example/fs_example.c \
$(CONTRIBDIR)/examples/httpd/https_example/https_example.c \
$(CONTRIBDIR)/examples/httpd/ssi_example/ssi_example.c \
$(CONTRIBDIR)/examples/lwiperf/lwiperf_example.c \
$(CONTRIBDIR)/examples/mdns/mdns_example.c \
$(CONTRIBDIR)/examples/mqtt/mqtt_example.c \
$(CONTRIBDIR)/examples/ppp/pppos_example.c \
$(CONTRIBDIR)/examples/snmp/snmp_private_mib/lwip_prvmib.c \
$(CONTRIBDIR)/examples/snmp/snmp_v3/snmpv3_dummy.c \
$(CONTRIBDIR)/examples/snmp/snmp_example.c \
$(CONTRIBDIR)/examples/sntp/sntp_example.c \
$(CONTRIBDIR)/examples/tftp/tftp_example.c \
$(CONTRIBDIR)/addons/tcp_isn/tcp_isn.c \
$(CONTRIBDIR)/addons/ipv6_static_routing/ip6_route_table.c

View File

@@ -1,5 +0,0 @@
A simple example of using LWIP_HOOK_DHCP_PARSE/APPEND_OPTION hooks to implement:
* DHCP_OPTION_MTU (option 26) to update the netif's MTU
* DHCP_OPTION_CLIENT_ID (option 61) to advertize client's HW id of LWIP_IANA_HWTYPE_ETHERNET type
Please follow the instructions in dhcp_extra_opts.h to add the hooks, definitions in lwipopts.h and enabling the extra options.

View File

@@ -1,91 +0,0 @@
/*
* Copyright (c) Espressif Systems (Shanghai) CO LTD
* 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. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
*/
#include <string.h>
#include "lwip/prot/dhcp.h"
#include "lwip/dhcp.h"
#include "lwip/netif.h"
#include "lwip/prot/iana.h"
void dhcp_parse_extra_opts(struct dhcp *dhcp, uint8_t state, uint8_t option, uint8_t len, struct pbuf* p, uint16_t offset)
{
LWIP_UNUSED_ARG(dhcp);
LWIP_UNUSED_ARG(state);
LWIP_UNUSED_ARG(option);
LWIP_UNUSED_ARG(len);
LWIP_UNUSED_ARG(p);
LWIP_UNUSED_ARG(offset);
#if LWIP_DHCP_ENABLE_MTU_UPDATE
if ((option == DHCP_OPTION_MTU) &&
(state == DHCP_STATE_REBOOTING || state == DHCP_STATE_REBINDING ||
state == DHCP_STATE_RENEWING || state == DHCP_STATE_REQUESTING)) {
u32_t mtu = 0;
struct netif *netif;
LWIP_ERROR("dhcp_parse_extra_opts(): MTU option's len != 2", len == 2, return;);
LWIP_ERROR("dhcp_parse_extra_opts(): extracting MTU option failed",
pbuf_copy_partial(p, &mtu, 2, offset) == 2, return;);
mtu = lwip_htons((u16_t)mtu);
NETIF_FOREACH(netif) {
/* find the netif related to this dhcp */
if (dhcp == netif_dhcp_data(netif)) {
if (mtu < netif->mtu) {
netif->mtu = mtu;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_parse_extra_opts(): Negotiated netif MTU is %d\n", netif->mtu));
}
return;
}
}
} /* DHCP_OPTION_MTU */
#endif /* LWIP_DHCP_ENABLE_MTU_UPDATE */
}
void dhcp_append_extra_opts(struct netif *netif, uint8_t state, struct dhcp_msg *msg_out, uint16_t *options_out_len)
{
LWIP_UNUSED_ARG(netif);
LWIP_UNUSED_ARG(state);
LWIP_UNUSED_ARG(msg_out);
LWIP_UNUSED_ARG(options_out_len);
#if LWIP_DHCP_ENABLE_CLIENT_ID
if (state == DHCP_STATE_RENEWING || state == DHCP_STATE_REBINDING ||
state == DHCP_STATE_REBOOTING || state == DHCP_STATE_OFF ||
state == DHCP_STATE_REQUESTING || state == DHCP_STATE_BACKING_OFF || state == DHCP_STATE_SELECTING) {
size_t i;
u8_t *options = msg_out->options + *options_out_len;
LWIP_ERROR("dhcp_append(client_id): options_out_len + 3 + netif->hwaddr_len <= DHCP_OPTIONS_LEN",
*options_out_len + 3U + netif->hwaddr_len <= DHCP_OPTIONS_LEN, return;);
*options_out_len = *options_out_len + netif->hwaddr_len + 3;
*options++ = DHCP_OPTION_CLIENT_ID;
*options++ = netif->hwaddr_len + 1; /* option size */
*options++ = LWIP_IANA_HWTYPE_ETHERNET;
for (i = 0; i < netif->hwaddr_len; i++) {
*options++ = netif->hwaddr[i];
}
}
#endif /* LWIP_DHCP_ENABLE_CLIENT_ID */
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (c) Espressif Systems (Shanghai) CO LTD
* 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. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
*
* To use these additional DHCP options, make sure this file is included in LWIP_HOOK_FILENAME
* and define these hooks:
*
* #define LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset) \
* do { LWIP_UNUSED_ARG(msg); \
* dhcp_parse_extra_opts(dhcp, state, option, len, pbuf, offset); \
* } while(0)
*
* #define LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, options_len_ptr) \
* dhcp_append_extra_opts(netif, state, msg, options_len_ptr);
*
* To enable (disable) these option, please set one or both of the below macros to 1 (0)
* #define LWIP_DHCP_ENABLE_MTU_UPDATE 1
* #define LWIP_DHCP_ENABLE_CLIENT_ID 1
*/
#ifndef LWIP_HDR_CONTRIB_ADDONS_DHCP_OPTS_H
#define LWIP_HDR_CONTRIB_ADDONS_DHCP_OPTS_H
/* Add standard integers so the header could be included before lwip */
#include <stdint.h>
/* Forward declare lwip structs */
struct dhcp;
struct pbuf;
struct dhcp;
struct netif;
struct dhcp_msg;
/* Internal hook functions */
void dhcp_parse_extra_opts(struct dhcp *dhcp, uint8_t state, uint8_t option, uint8_t len, struct pbuf* p, uint16_t offset);
void dhcp_append_extra_opts(struct netif *netif, uint8_t state, struct dhcp_msg *msg_out, uint16_t *options_out_len);
#endif /* LWIP_HDR_CONTRIB_ADDONS_DHCP_OPTS_H */

View File

@@ -1,43 +0,0 @@
A simple routing table implementation for addition, deletion and lookup of IPv6 routes. 
APIs are:
1) s8_t ip6_add_route_entry(struct ip6_prefix *ip6_prefix,
                            struct netif *netif,
                            ip6_addr_t *gateway,
                            s8_t *index);
2) err_t ip6_remove_route_entry(struct ip6_prefix *ip6_prefix);
3) s8_t ip6_find_route_entry(ip6_addr_t *ip6_dest_addr);
4) struct netif *ip6_static_route(ip6_addr_t *src, ip6_addr_t *dest);
5) ip6_addr_t *ip6_get_gateway(struct netif *netif, ip6_addr_t *dest);
6) struct ip6_route_entry *ip6_get_route_table(void);
For route lookup from the table, The LWIP_HOOK_IP6_ROUTE hook in ip6_route(..) of ip6.c
could be assigned to the ip6_static_route() API of this implementation to return the
appropriate netif.
-- The application can add routes using the API ip6_add_route_entry(..). 
   This API adds the ip6 prefix route into the static route table while
   keeping all entries sorted in decreasing order of prefix length.
   Subsequently, a linear search down the list can be performed to retrieve a
   matching route entry for a Longest Prefix Match.
   The prefix length is expected to be at an 8-bit boundary. While this is 
   a limitation, it would serve most practical purposes.
-- The application can remove routes using the API ip6_remove_route_entry(..).
-- The application can find a route entry for a specific address using the 
   ip6_find_route_entry() function which returns the index of the found entry. 
   This is used internally by the route lookup function ip6_static_route() API.
-- To fetch the gateway IPv6 address for a specific destination IPv6 
   address and target netif, the application can call ip6_get_gateway(..).
This API could be assigned to the LWIP_HOOK_ND6_GET_GW() if a gateway has
been added as part of the ip6_add_route_entry().
-- To fetch a pointer to the head of the table, the application can call 
   ip6_get_route_table().

View File

@@ -1,248 +0,0 @@
/**
* @file
* IPv6 static route table.
*/
/*
* Copyright (c) 2015 Nest Labs, Inc.
* 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.
*
* Author: Pradip De <pradipd@google.com>
*
*
* Please coordinate changes and requests with Pradip De
* <pradipd@google.com>
*/
#include "lwip/opt.h"
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
#include "ip6_route_table.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/netif.h"
#include "lwip/ip6.h"
#include "lwip/ip6_addr.h"
#include "lwip/nd6.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "string.h"
static struct ip6_route_entry static_route_table[LWIP_IPV6_NUM_ROUTE_ENTRIES];
/**
* Add the ip6 prefix route and target netif into the static route table while
* keeping all entries sorted in decreasing order of prefix length.
* 1. Search from the last entry up to find the correct slot to insert while
* moving entries one position down to create room.
* 2. Insert into empty slot created.
*
* Subsequently, a linear search down the list can be performed to retrieve a
* matching route entry for a Longest Prefix Match.
*
* @param ip6_prefix the route prefix entry to add.
* @param netif pointer to target netif.
* @param gateway the gateway address to use to send through. Has to be link local.
* @param idx return value argument of index where route entry was added in table.
* @return ERR_OK if addition was successful.
* ERR_MEM if table is already full.
* ERR_ARG if passed argument is bad or route already exists in table.
*/
err_t
ip6_add_route_entry(const struct ip6_prefix *ip6_prefix, struct netif *netif, const ip6_addr_t *gateway, s8_t *idx)
{
s8_t i = -1;
err_t retval = ERR_OK;
if (!ip6_prefix_valid(ip6_prefix->prefix_len) || (netif == NULL)) {
retval = ERR_ARG;
goto exit;
}
/* Check if an entry already exists with matching prefix; If so, replace it. */
for (i = 0; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
if ((ip6_prefix->prefix_len == static_route_table[i].prefix.prefix_len) &&
memcmp(&ip6_prefix->addr, &static_route_table[i].prefix.addr,
ip6_prefix->prefix_len / 8) == 0) {
/* Prefix matches; replace the netif with the one being added. */
goto insert;
}
}
/* Check if the table is full */
if (static_route_table[LWIP_IPV6_NUM_ROUTE_ENTRIES - 1].netif != NULL) {
retval = ERR_MEM;
goto exit;
}
/* Shift all entries down the table until slot is found */
for (i = LWIP_IPV6_NUM_ROUTE_ENTRIES - 1;
i > 0 && (ip6_prefix->prefix_len > static_route_table[i - 1].prefix.prefix_len); i--) {
SMEMCPY(&static_route_table[i], &static_route_table[i - 1], sizeof(struct ip6_route_entry));
}
insert:
/* Insert into the slot selected */
SMEMCPY(&static_route_table[i].prefix, ip6_prefix, sizeof(struct ip6_prefix));
static_route_table[i].netif = netif;
/* Add gateway to route table */
static_route_table[i].gateway = gateway;
if (idx != NULL) {
*idx = i;
}
exit:
return retval;
}
/**
* Removes the route entry from the static route table.
*
* @param ip6_prefix the route prefix entry to delete.
*/
void
ip6_remove_route_entry(const struct ip6_prefix *ip6_prefix)
{
int i, pos = -1;
for (i = 0; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
/* compare prefix to find position to delete */
if (ip6_prefix->prefix_len == static_route_table[i].prefix.prefix_len &&
memcmp(&ip6_prefix->addr, &static_route_table[i].prefix.addr,
ip6_prefix->prefix_len / 8) == 0) {
pos = i;
break;
}
}
if (pos >= 0) {
/* Shift everything beyond pos one slot up */
for (i = pos; i < LWIP_IPV6_NUM_ROUTE_ENTRIES - 1; i++) {
SMEMCPY(&static_route_table[i], &static_route_table[i+1], sizeof(struct ip6_route_entry));
if (static_route_table[i].netif == NULL) {
break;
}
}
/* Zero the remaining entries */
for (; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
ip6_addr_set_zero((&static_route_table[i].prefix.addr));
static_route_table[i].netif = NULL;
}
}
}
/**
* Finds the appropriate route entry in the static route table corresponding to the given
* destination IPv6 address. Since the entries in the route table are kept sorted in decreasing
* order of prefix length, a linear search down the list is performed to retrieve a matching
* index.
*
* @param ip6_dest_addr the destination address to match
* @return the idx of the found route entry; -1 if not found.
*/
s8_t
ip6_find_route_entry(const ip6_addr_t *ip6_dest_addr)
{
s8_t i, idx = -1;
/* Search prefix in the sorted(decreasing order of prefix length) list */
for(i = 0; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
if (memcmp(ip6_dest_addr, &static_route_table[i].prefix.addr,
static_route_table[i].prefix.prefix_len / 8) == 0) {
idx = i;
break;
}
}
return idx;
}
/**
* Finds the appropriate network interface for a given IPv6 address from a routing table with
* static IPv6 routes.
*
* @param src the source IPv6 address, if known
* @param dest the destination IPv6 address for which to find the route
* @return the netif on which to send to reach dest
*/
struct netif *
ip6_static_route(const ip6_addr_t *src, const ip6_addr_t *dest)
{
int i;
LWIP_UNUSED_ARG(src);
/* Perform table lookup */
i = ip6_find_route_entry(dest);
if (i >= 0) {
return static_route_table[i].netif;
} else {
return NULL;
}
}
/**
* Finds the gateway IP6 address for a given destination IPv6 address and target netif
* from a routing table with static IPv6 routes.
*
* @param netif the netif used for sending
* @param dest the destination IPv6 address
* @return the ip6 address of the gateway to forward packet to
*/
const ip6_addr_t *
ip6_get_gateway(struct netif *netif, const ip6_addr_t *dest)
{
const ip6_addr_t *ret_gw = NULL;
const int i = ip6_find_route_entry(dest);
LWIP_UNUSED_ARG(netif);
if (i >= 0) {
if (static_route_table[i].gateway != NULL) {
ret_gw = static_route_table[i].gateway;
}
}
return ret_gw;
}
/**
* Returns the top of the route table.
* This should be used for debug printing only.
*
* @return the top of the route table.
*/
const struct ip6_route_entry *
ip6_get_route_table(void)
{
return static_route_table;
}
#endif /* LWIP_IPV6 */

View File

@@ -1,94 +0,0 @@
/**
* @file
*
* IPv6 static route table.
*/
/*
* Copyright (c) 2015 Nest Labs, Inc.
* 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.
*
* Author: Pradip De <pradipd@google.com>
*
*
* Please coordinate changes and requests with Pradip De
* <pradipd@google.com>
*/
#ifndef __LWIP_IP6_ROUTE_TABLE_H__
#define __LWIP_IP6_ROUTE_TABLE_H__
#include "lwip/opt.h"
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
#include "lwip/ip6_addr.h"
#include "lwip/err.h"
#ifdef __cplusplus
extern "C" {
#endif
struct netif;
/**
* LWIP_IPV6_NUM_ROUTES: Number of IPV6 routes that can be kept in the static route table.
*/
#ifndef LWIP_IPV6_NUM_ROUTE_ENTRIES
#define LWIP_IPV6_NUM_ROUTE_ENTRIES (8)
#endif
#define IP6_MAX_PREFIX_LEN (128)
#define IP6_PREFIX_ALLOWED_GRANULARITY (8)
/* Prefix length cannot be greater than 128 bits and needs to be at a byte boundary */
#define ip6_prefix_valid(prefix_len) (((prefix_len) <= IP6_MAX_PREFIX_LEN) && \
(((prefix_len) % IP6_PREFIX_ALLOWED_GRANULARITY) == 0))
struct ip6_prefix {
ip6_addr_t addr;
u8_t prefix_len; /* prefix length in bits at byte boundaries */
};
struct ip6_route_entry {
struct ip6_prefix prefix;
struct netif *netif;
const ip6_addr_t *gateway;
};
err_t ip6_add_route_entry(const struct ip6_prefix *ip6_prefix, struct netif *netif,
const ip6_addr_t *gateway, s8_t *idx);
void ip6_remove_route_entry(const struct ip6_prefix *ip6_prefix);
s8_t ip6_find_route_entry(const ip6_addr_t *ip6_dest_addr);
struct netif *ip6_static_route(const ip6_addr_t *src, const ip6_addr_t *dest);
const ip6_addr_t *ip6_get_gateway(struct netif *netif, const ip6_addr_t *dest);
const struct ip6_route_entry *ip6_get_route_table(void);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_IPV6 */
#endif /* __LWIP_IP6_ROUTE_TABLE_H__ */

View File

@@ -1,164 +0,0 @@
/**
* @file
* DNS-SD APIs used by LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE
*
* This implementation assumes the DNS-SD API implementation (most likely provided by
* mDNSResponder) is implemented in the same process space as LwIP and can directly
* invoke the callback for DNSServiceGetAddrInfo. This is the typical deployment in
* an embedded environment where as a traditional OS requires pumping the callback results
* through an IPC mechanism (see DNSServiceRefSockFD/DNSServiceProcessResult)
*
* @defgroup dnssd DNS-SD
* @ingroup dns
*/
/*
* Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. <joel.cunningham@garmin.com>
* 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: Joel Cunningham <joel.cunningham@me.com>
*
*/
#include "lwip/opt.h"
#include "lwip/err.h"
#include "lwip/inet.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include "dnssd.h"
/* External headers */
#include <string.h>
#include <dns_sd.h>
/* This timeout should allow for multiple queries.
mDNSResponder has the following query timeline:
Query 1: time = 0s
Query 2: time = 1s
Query 3: time = 4s
*/
#define GETADDR_TIMEOUT_MS 5000
#define LOCAL_DOMAIN ".local"
/* Only consume .local hosts */
#ifndef CONSUME_LOCAL_ONLY
#define CONSUME_LOCAL_ONLY 1
#endif
struct addr_clbk_msg {
sys_sem_t sem;
struct sockaddr_storage addr;
err_t err;
};
static void addr_info_callback(DNSServiceRef ref, DNSServiceFlags flags, u32_t interface_index,
DNSServiceErrorType error_code, char const* hostname,
const struct sockaddr* address, u32_t ttl, void* context);
int
lwip_dnssd_gethostbyname(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err)
{
DNSServiceErrorType result;
DNSServiceRef ref;
struct addr_clbk_msg msg;
char *p;
/* @todo: use with IPv6 */
LWIP_UNUSED_ARG(addrtype);
#if CONSUME_LOCAL_ONLY
/* check if this is a .local host. If it is, then we consume the query */
p = strstr(name, LOCAL_DOMAIN);
if (p == NULL) {
return 0; /* not consumed */
}
p += (sizeof(LOCAL_DOMAIN) - 1);
/* check to make sure .local isn't a substring (only allow .local\0 or .local.\0) */
if ((*p != '.' && *p != '\0') ||
(*p == '.' && *(p + 1) != '\0')) {
return 0; /* not consumed */
}
#endif /* CONSUME_LOCAL_ONLY */
msg.err = sys_sem_new(&msg.sem, 0);
if (msg.err != ERR_OK) {
goto query_done;
}
msg.err = ERR_TIMEOUT;
result = DNSServiceGetAddrInfo(&ref, 0, 0, kDNSServiceProtocol_IPv4, name, addr_info_callback, &msg);
if (result == kDNSServiceErr_NoError) {
sys_arch_sem_wait(&msg.sem, GETADDR_TIMEOUT_MS);
DNSServiceRefDeallocate(ref);
/* We got a response */
if (msg.err == ERR_OK) {
struct sockaddr_in* addr_in = (struct sockaddr_in *)&msg.addr;
if (addr_in->sin_family == AF_INET) {
inet_addr_to_ip4addr(ip_2_ip4(addr), &addr_in->sin_addr);
} else {
/* @todo add IPv6 support */
msg.err = ERR_VAL;
}
}
}
sys_sem_free(&msg.sem);
/* Query has been consumed and is finished */
query_done:
*err = msg.err;
return 1;
}
static void
addr_info_callback(DNSServiceRef ref, DNSServiceFlags flags, u32_t interface_index,
DNSServiceErrorType error_code, char const* hostname,
const struct sockaddr* address, u32_t ttl, void* context)
{
struct addr_clbk_msg* msg = (struct addr_clbk_msg*)context;
struct sockaddr_in* addr_in = (struct sockaddr_in *)address;
LWIP_UNUSED_ARG(ref);
LWIP_UNUSED_ARG(flags);
LWIP_UNUSED_ARG(interface_index);
LWIP_UNUSED_ARG(hostname);
LWIP_UNUSED_ARG(ttl);
LWIP_UNUSED_ARG(context);
if ((error_code == kDNSServiceErr_NoError) &&
(addr_in->sin_family == AF_INET)) {
MEMCPY(&msg->addr, addr_in, sizeof(*addr_in));
msg->err = ERR_OK;
}
else {
/* @todo add IPv6 support */
msg->err = ERR_VAL;
}
sys_sem_signal(&msg->sem);
} /* addr_info_callback() */

View File

@@ -1,50 +0,0 @@
/**
* @file
* DNS-SD APIs used by LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE
*
* @defgroup dnssd DNS-SD
* @ingroup dns
*/
/*
* Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. <joel.cunningham@garmin.com>
* 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: Joel Cunningham <joel.cunningham@me.com>
*
*/
#include "lwip/opt.h"
#ifndef LWIP_HDR_DNSSD_H
#define LWIP_HDR_DNSSD_H
#include "lwip/err.h"
#include "lwip/ip_addr.h"
int lwip_dnssd_gethostbyname(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err);
#endif /* LWIP_HDR_DNSSD_H */

View File

@@ -1,182 +0,0 @@
/**
* @file
*
* Reference implementation of the TCP ISN algorithm standardized in RFC 6528.
* Produce TCP Initial Sequence Numbers by combining an MD5-generated hash
* based on the new TCP connection's identity and a stable secret, with the
* current time at 4-microsecond granularity.
*
* Specifically, the implementation uses MD5 to compute a hash of the input
* buffer, which contains both the four-tuple of the new TCP connection (local
* and remote IP address and port), as well as a 16-byte secret to make the
* results unpredictable to external parties. The secret must be given at
* initialization time and should ideally remain the same across system
* reboots. To be sure: the spoofing-resistance of the resulting ISN depends
* mainly on the strength of the supplied secret!
*
* The implementation takes 32 bits from the computed hash, and adds to it the
* current time, in 4-microsecond units. The current time is computed from a
* boot time given at initialization, and the current uptime as provided by
* sys_now(). Thus, it assumes that sys_now() returns a time value that is
* relative to the boot time, i.e., that it starts at 0 at system boot, and
* only ever increases monotonically.
*
* For efficiency reasons, a single MD5 input buffer is used, and partially
* filled in at initialization time. Specifically, of this 64-byte buffer, the
* first 36 bytes are used for the four-way TCP tuple data, followed by the
* 16-byte secret, followed by 12-byte zero padding. The 64-byte size of the
* buffer should achieve the best performance for the actual MD5 computation.
*
* Basic usage:
*
* 1. in your lwipopts.h, add the following lines:
*
* #include <lwip/arch.h>
* struct ip_addr;
* u32_t lwip_hook_tcp_isn(const struct ip_addr *local_ip, u16_t local_port,
* const struct ip_addr *remote_ip, u16_t remote_port);
* "#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn";
*
* 2. from your own code, call lwip_init_tcp_isn() at initialization time, with
* appropriate parameters.
*/
/*
* Copyright (c) 2016 The MINIX 3 Project.
* 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.
*
* Author: David van Moolenbroek <david@minix3.org>
*/
#include "tcp_isn.h"
#include "lwip/ip_addr.h"
#include "lwip/sys.h"
#include <string.h>
#ifdef LWIP_HOOK_TCP_ISN
/* pull in md5 of ppp? */
#include "netif/ppp/ppp_opts.h"
#if !PPP_SUPPORT || (!LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS)
#undef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5 1
#include "netif/ppp/polarssl/md5.h"
#endif
static u8_t input[64];
static u32_t base_time;
/**
* Initialize the TCP ISN module, with the boot time and a secret.
*
* @param boot_time Wall clock boot time of the system, in seconds.
* @param secret_16_bytes A 16-byte secret used to randomize the TCP ISNs.
*/
void
lwip_init_tcp_isn(u32_t boot_time, const u8_t *secret_16_bytes)
{
/* Initialize the input buffer with the secret and trailing zeroes. */
memset(input, 0, sizeof(input));
MEMCPY(&input[36], secret_16_bytes, 16);
/* Save the boot time in 4-us units. Overflow is no problem here. */
base_time = boot_time * 250000;
}
/**
* Hook to generate an Initial Sequence Number (ISN) for a new TCP connection.
*
* @param local_ip The local IP address.
* @param local_port The local port number, in host-byte order.
* @param remote_ip The remote IP address.
* @param remote_port The remote port number, in host-byte order.
* @return The ISN to use for the new TCP connection.
*/
u32_t
lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port,
const ip_addr_t *remote_ip, u16_t remote_port)
{
md5_context ctx;
u8_t output[16];
u32_t isn;
#if LWIP_IPV4 && LWIP_IPV6
if (IP_IS_V6(local_ip))
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV6
{
const ip6_addr_t *local_ip6, *remote_ip6;
local_ip6 = ip_2_ip6(local_ip);
remote_ip6 = ip_2_ip6(remote_ip);
SMEMCPY(&input[0], &local_ip6->addr, 16);
SMEMCPY(&input[16], &remote_ip6->addr, 16);
}
#endif /* LWIP_IPV6 */
#if LWIP_IPV4 && LWIP_IPV6
else
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV4
{
const ip4_addr_t *local_ip4, *remote_ip4;
local_ip4 = ip_2_ip4(local_ip);
remote_ip4 = ip_2_ip4(remote_ip);
/* Represent IPv4 addresses as IPv4-mapped IPv6 addresses, to ensure that
* the IPv4 and IPv6 address spaces are completely disjoint. */
memset(&input[0], 0, 10);
input[10] = 0xff;
input[11] = 0xff;
SMEMCPY(&input[12], &local_ip4->addr, 4);
memset(&input[16], 0, 10);
input[26] = 0xff;
input[27] = 0xff;
SMEMCPY(&input[28], &remote_ip4->addr, 4);
}
#endif /* LWIP_IPV4 */
input[32] = (u8_t)(local_port >> 8);
input[33] = (u8_t)(local_port & 0xff);
input[34] = (u8_t)(remote_port >> 8);
input[35] = (u8_t)(remote_port & 0xff);
/* The secret and padding are already filled in. */
/* Generate the hash, using MD5. */
md5_starts(&ctx);
md5_update(&ctx, input, sizeof(input));
md5_finish(&ctx, output);
/* Arbitrarily take the first 32 bits from the generated hash. */
MEMCPY(&isn, output, sizeof(isn));
/* Add the current time in 4-microsecond units. */
return isn + base_time + sys_now() * 250;
}
#endif /* LWIP_HOOK_TCP_ISN */

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2016 The MINIX 3 Project.
* 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.
*
* Author: David van Moolenbroek <david@minix3.org>
*/
#ifndef LWIP_HDR_CONTRIB_ADDONS_TCP_ISN_H
#define LWIP_HDR_CONTRIB_ADDONS_TCP_ISN_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern "C" {
#endif
void lwip_init_tcp_isn(u32_t boot_time, const u8_t *secret_16_bytes);
u32_t lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port,
const ip_addr_t *remote_ip, u16_t remote_port);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_HDR_CONTRIB_ADDONS_TCP_ISN_H */

View File

@@ -1,27 +0,0 @@
This folder provides an example implementation of how to add custom tcp header
options and custom socket options.
It does this by implementing the (seldom used) tcp md5 signature.
To enable it, add an LWIP_HOOK_FILENAME hook file, include tcp_md5.h in it and
define these hooks:
#define LWIP_HOOK_TCP_INPACKET_PCB(pcb, hdr, optlen, opt1len, opt2, p) tcp_md5_check_inpacket(pcb, hdr, optlen, opt1len, opt2, p)
#define LWIP_HOOK_TCP_OPT_LENGTH_SEGMENT(pcb, internal_len) tcp_md5_get_additional_option_length(pcb, internal_len)
#define LWIP_HOOK_TCP_ADD_TX_OPTIONS(p, hdr, pcb, opts) tcp_md5_add_tx_options(p, hdr, pcb, opts)
#define LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) tcp_md5_setsockopt_hook(sock, level, optname, optval, optlen, err)
Then, in your sockets application, enable md5 signature on a socket like this:
struct tcp_md5sig md5;
struct sockaddr_storage addr_remote; /* Initialize this to remote address and port */
memcpy(&md5.tcpm_addr, &addr_remote, sizeof(addr_remote));
strcpy(md5.tcpm_key, key); /* this is the md5 key per connection */
md5.tcpm_keylen = strlen(key);
if ((ret = setsockopt(sockfd, IPPROTO_TCP, TCP_MD5SIG, &md5, sizeof(md5))) < 0) {
perror("setsockopt TCP_MD5SIG");
return;
}
After that, your connection (client) or all incoming connections (server) require
tcp md5 signatures.

View File

@@ -1,534 +0,0 @@
/**
* @file: An implementation of TCP MD5 signatures by using various hooks in
* lwIP to implement custom tcp options and custom socket options.
*/
/*
* Copyright (c) 2018 Simon Goldschmidt
* 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.
*
* Author: Simon Goldschmidt <goldsimon@gmx.de>
*/
#include "tcp_md5.h"
#include "lwip/ip_addr.h"
#include "lwip/sys.h"
#include "lwip/prot/tcp.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/sockets.h"
#include "lwip/priv/sockets_priv.h"
#include "lwip/api.h"
#include <string.h>
/* pull in md5 of ppp? */
#include "netif/ppp/ppp_opts.h"
#if !PPP_SUPPORT || (!LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS)
#undef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5 1
#include "netif/ppp/polarssl/md5.h"
#endif
#if !LWIP_TCP_PCB_NUM_EXT_ARGS
#error tcp_md5 needs LWIP_TCP_PCB_NUM_EXT_ARGS
#endif
#define LWIP_TCP_OPT_MD5 19 /* number of the md5 option */
#define LWIP_TCP_OPT_LEN_MD5 18 /* length of the md5 option */
#define LWIP_TCP_OPT_LEN_MD5_OUT 20 /* 18 + alignment */
#define LWIP_TCP_MD5_DIGEST_LEN 16
/* This keeps the md5 state internally */
struct tcp_md5_conn_info {
struct tcp_md5_conn_info *next;
ip_addr_t remote_addr;
u16_t remote_port;
u8_t key[TCP_MD5SIG_MAXKEYLEN];
u16_t key_len;
};
/* Callback function prototypes: */
static void tcp_md5_extarg_destroy(u8_t id, void *data);
static err_t tcp_md5_extarg_passive_open(u8_t id, struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb);
/* Define our tcp ext arg callback structure: */
const struct tcp_ext_arg_callbacks tcp_md5_ext_arg_callbacks = {
tcp_md5_extarg_destroy,
tcp_md5_extarg_passive_open
};
static u8_t tcp_md5_extarg_id = LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID;
static u8_t tcp_md5_opts_buf[40];
/** Initialize this module (allocates a tcp ext arg id) */
void
tcp_md5_init(void)
{
tcp_md5_extarg_id = tcp_ext_arg_alloc_id();
}
/* Create a conn-info structure that holds the md5 state per connection */
static struct tcp_md5_conn_info *
tcp_md5_conn_info_alloc(void)
{
return (struct tcp_md5_conn_info *)mem_malloc(sizeof(struct tcp_md5_conn_info));
}
/* Frees a conn-info structure that holds the md5 state per connection */
static void
tcp_md5_conn_info_free(struct tcp_md5_conn_info *info)
{
mem_free(info);
}
/* A pcb is about to be destroyed. Free its extdata */
static void
tcp_md5_extarg_destroy(u8_t id, void *data)
{
struct tcp_md5_conn_info *iter;
LWIP_ASSERT("tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID",
tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID);
LWIP_ASSERT("id == tcp_md5_extarg_id", id == tcp_md5_extarg_id);
LWIP_UNUSED_ARG(id);
iter = (struct tcp_md5_conn_info *)data;
while (iter != NULL) {
struct tcp_md5_conn_info *info = iter;
iter = iter->next;
tcp_md5_conn_info_free(info);
}
}
/* Try to find an md5 connection info for the specified remote connection */
static struct tcp_md5_conn_info *
tcp_md5_get_info(const struct tcp_pcb *pcb, const ip_addr_t *remote_ip, u16_t remote_port)
{
if (pcb != NULL) {
struct tcp_md5_conn_info *info = (struct tcp_md5_conn_info *)tcp_ext_arg_get(pcb, tcp_md5_extarg_id);
while (info != NULL) {
if (ip_addr_eq(&info->remote_addr, remote_ip)) {
if (info->remote_port == remote_port) {
return info;
}
}
info = info->next;
}
}
return NULL;
}
/* Passive open: copy md5 connection info from listen pcb to connection pcb
* or return error (connection will be closed)
*/
static err_t
tcp_md5_extarg_passive_open(u8_t id, struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb)
{
struct tcp_md5_conn_info *iter;
LWIP_ASSERT("lpcb != NULL", lpcb != NULL);
LWIP_ASSERT("cpcb != NULL", cpcb != NULL);
LWIP_ASSERT("tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID",
tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID);
LWIP_ASSERT("id == tcp_md5_extarg_id", id == tcp_md5_extarg_id);
LWIP_UNUSED_ARG(id);
iter = (struct tcp_md5_conn_info *)tcp_ext_arg_get((struct tcp_pcb *)lpcb, id);
while (iter != NULL) {
if (iter->remote_port == cpcb->remote_port) {
if (ip_addr_eq(&iter->remote_addr, &cpcb->remote_ip)) {
struct tcp_md5_conn_info *info = tcp_md5_conn_info_alloc();
if (info != NULL) {
memcpy(info, iter, sizeof(struct tcp_md5_conn_info));
tcp_ext_arg_set(cpcb, id, info);
tcp_ext_arg_set_callbacks(cpcb, id, &tcp_md5_ext_arg_callbacks);
return ERR_OK;
} else {
return ERR_MEM;
}
}
}
iter = iter->next;
}
/* remote connection not found */
return ERR_VAL;
}
/* Parse tcp header options and return 1 if an md5 signature option was found */
static int
tcp_md5_parseopt(const u8_t *opts, u16_t optlen, u8_t *md5_digest_out)
{
u8_t data;
u16_t optidx;
/* Parse the TCP MSS option, if present. */
if (optlen != 0) {
for (optidx = 0; optidx < optlen; ) {
u8_t opt = opts[optidx++];
switch (opt) {
case LWIP_TCP_OPT_EOL:
/* End of options. */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: EOL\n"));
return 0;
case LWIP_TCP_OPT_NOP:
/* NOP option. */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: NOP\n"));
break;
case LWIP_TCP_OPT_MD5:
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: MD5\n"));
if (opts[optidx++] != LWIP_TCP_OPT_LEN_MD5 || (optidx - 2 + LWIP_TCP_OPT_LEN_MD5) > optlen) {
/* Bad length */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n"));
return 0;
}
/* An MD5 option with the right option length. */
memcpy(md5_digest_out, &opts[optidx], LWIP_TCP_MD5_DIGEST_LEN);
/* no need to process the options further */
return 1;
break;
default:
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: other\n"));
data = opts[optidx++];
if (data < 2) {
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n"));
/* If the length field is zero, the options are malformed
and we don't process them further. */
return 0;
}
/* All other options have a length field, so that we easily
can skip past them. */
optidx += data - 2;
}
}
}
return 0;
}
/* Get tcp options into contiguous memory. May be required if input pbufs
* are chained.
*/
static const u8_t*
tcp_md5_options_singlebuf(struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2)
{
const u8_t *opts;
LWIP_ASSERT("hdr != NULL", hdr != NULL);
LWIP_ASSERT("optlen >= opt1len", optlen >= opt1len);
opts = (const u8_t *)hdr + TCP_HLEN;
if (optlen == opt1len) {
/* arleady in one piece */
return opts;
}
if (optlen > sizeof(tcp_md5_opts_buf)) {
/* options too long */
return NULL;
}
LWIP_ASSERT("opt2 != NULL", opt2 != NULL);
/* copy first part */
memcpy(tcp_md5_opts_buf, opts, opt1len);
/* copy second part */
memcpy(&tcp_md5_opts_buf[opt1len], opt2, optlen - opt1len);
return tcp_md5_opts_buf;
}
/* Create the md5 digest for a given segment */
static int
tcp_md5_create_digest(const ip_addr_t *ip_src, const ip_addr_t *ip_dst, const struct tcp_hdr *hdr,
const u8_t *key, size_t key_len, u8_t *digest_out, struct pbuf *p)
{
md5_context ctx;
u8_t tmp8;
u16_t tmp16;
const size_t addr_len = IP_ADDR_RAW_SIZE(*ip_src);
if (p != NULL) {
LWIP_ASSERT("pbuf must not point to tcp header here!", (const void *)hdr != p->payload);
}
/* Generate the hash, using MD5. */
md5_starts(&ctx);
/* 1. the TCP pseudo-header (in the order: source IP address,
destination IP address, zero-padded protocol number, and
segment length) */
md5_update(&ctx, (const unsigned char*)ip_src, addr_len);
md5_update(&ctx, (const unsigned char*)ip_dst, addr_len);
tmp8 = 0; /* zero-padded */
md5_update(&ctx, &tmp8, 1);
tmp8 = IP_PROTO_TCP;
md5_update(&ctx, &tmp8, 1);
tmp16 = lwip_htons(TCPH_HDRLEN_BYTES(hdr) + (p ? p->tot_len : 0));
md5_update(&ctx, (const unsigned char*)&tmp16, 2);
/* 2. the TCP header, excluding options, and assuming a checksum of
zero */
md5_update(&ctx, (const unsigned char*)hdr, sizeof(struct tcp_hdr));
/* 3. the TCP segment data (if any) */
if ((p != NULL) && (p->tot_len != 0)) {
struct pbuf *q;
for (q = p; q != NULL; q = q->next) {
md5_update(&ctx, (const unsigned char*)q->payload, q->len);
}
}
/* 4. an independently-specified key or password, known to both TCPs
and presumably connection-specific */
md5_update(&ctx, key, key_len);
md5_finish(&ctx, digest_out);
return 1;
}
/* Duplicate a tcp header and make sure the fields are in network byte order */
static void
tcp_md5_dup_tcphdr(struct tcp_hdr *tcphdr_copy, const struct tcp_hdr *tcphdr_in, int tcphdr_in_is_host_order)
{
memcpy(tcphdr_copy, tcphdr_in, sizeof(struct tcp_hdr));
tcphdr_copy->chksum = 0; /* checksum is zero for the pseudo header */
if (tcphdr_in_is_host_order) {
/* lwIP writes the TCP header values back to the buffer, we need to invert that here: */
tcphdr_copy->src = lwip_htons(tcphdr_copy->src);
tcphdr_copy->dest = lwip_htons(tcphdr_copy->dest);
tcphdr_copy->seqno = lwip_htonl(tcphdr_copy->seqno);
tcphdr_copy->ackno = lwip_htonl(tcphdr_copy->ackno);
tcphdr_copy->wnd = lwip_htons(tcphdr_copy->wnd);
tcphdr_copy->urgp = lwip_htons(tcphdr_copy->urgp);
}
}
/* Check if md5 is enabled on a given pcb */
static int
tcp_md5_is_enabled_on_pcb(const struct tcp_pcb *pcb)
{
if (tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID) {
struct tcp_md5_conn_info *info = (struct tcp_md5_conn_info *)tcp_ext_arg_get(pcb, tcp_md5_extarg_id);
if (info != NULL) {
return 1;
}
}
return 0;
}
/* Check if md5 is enabled on a given listen pcb */
static int
tcp_md5_is_enabled_on_lpcb(const struct tcp_pcb_listen *lpcb)
{
/* same as for connection pcbs */
return tcp_md5_is_enabled_on_pcb((const struct tcp_pcb *)lpcb);
}
/* Hook implementation for LWIP_HOOK_TCP_OPT_LENGTH_SEGMENT */
u8_t
tcp_md5_get_additional_option_length(const struct tcp_pcb *pcb, u8_t internal_option_length)
{
if ((pcb != NULL) && tcp_md5_is_enabled_on_pcb(pcb)) {
u8_t new_option_length = internal_option_length + LWIP_TCP_OPT_LEN_MD5_OUT;
LWIP_ASSERT("overflow", new_option_length > internal_option_length);
LWIP_ASSERT("options too long", new_option_length <= TCP_MAX_OPTION_BYTES);
return new_option_length;
}
return internal_option_length;
}
/* Hook implementation for LWIP_HOOK_TCP_INPACKET_PCB when called for listen pcbs */
static err_t
tcp_md5_check_listen(struct tcp_pcb_listen* lpcb, struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2)
{
LWIP_ASSERT("lpcb != NULL", lpcb != NULL);
if (tcp_md5_is_enabled_on_lpcb(lpcb)) {
const u8_t *opts;
u8_t digest_received[LWIP_TCP_MD5_DIGEST_LEN];
u8_t digest_calculated[LWIP_TCP_MD5_DIGEST_LEN];
const struct tcp_md5_conn_info *info = tcp_md5_get_info((struct tcp_pcb *)lpcb, ip_current_src_addr(), hdr->src);
if (info != NULL) {
opts = tcp_md5_options_singlebuf(hdr, optlen, opt1len, opt2);
if (opts != NULL) {
if (tcp_md5_parseopt(opts, optlen, digest_received)) {
struct tcp_hdr tcphdr_copy;
tcp_md5_dup_tcphdr(&tcphdr_copy, hdr, 1);
if (tcp_md5_create_digest(ip_current_src_addr(), ip_current_dest_addr(), &tcphdr_copy, info->key, info->key_len, digest_calculated, NULL)) {
/* everything set up, compare the digests */
if (!memcmp(digest_received, digest_calculated, LWIP_TCP_MD5_DIGEST_LEN)) {
/* equal */
return ERR_OK;
}
/* not equal */
}
}
}
}
/* md5 enabled on this pcb but no match or other error -> fail */
return ERR_VAL;
}
return ERR_OK;
}
/* Hook implementation for LWIP_HOOK_TCP_INPACKET_PCB */
err_t
tcp_md5_check_inpacket(struct tcp_pcb* pcb, struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2, struct pbuf *p)
{
LWIP_ASSERT("pcb != NULL", pcb != NULL);
if (pcb->state == LISTEN) {
return tcp_md5_check_listen((struct tcp_pcb_listen *)pcb, hdr, optlen, opt1len, opt2);
}
if (tcp_md5_is_enabled_on_pcb(pcb)) {
const struct tcp_md5_conn_info *info = tcp_md5_get_info(pcb, ip_current_src_addr(), hdr->src);
if (info != NULL) {
const u8_t *opts;
u8_t digest_received[LWIP_TCP_MD5_DIGEST_LEN];
u8_t digest_calculated[LWIP_TCP_MD5_DIGEST_LEN];
opts = tcp_md5_options_singlebuf(hdr, optlen, opt1len, opt2);
if (opts != NULL) {
if (tcp_md5_parseopt(opts, optlen, digest_received)) {
struct tcp_hdr hdr_copy;
tcp_md5_dup_tcphdr(&hdr_copy, hdr, 1);
if (tcp_md5_create_digest(&pcb->remote_ip, &pcb->local_ip, &hdr_copy, info->key, info->key_len, digest_calculated, p)) {
/* everything set up, compare the digests */
if (!memcmp(digest_received, digest_calculated, LWIP_TCP_MD5_DIGEST_LEN)) {
/* equal */
return ERR_OK;
}
/* not equal */
}
}
}
}
/* md5 enabled on this pcb but no match or other error -> fail */
return ERR_VAL;
}
return ERR_OK;
}
/* Hook implementation for LWIP_HOOK_TCP_ADD_TX_OPTIONS */
u32_t *
tcp_md5_add_tx_options(struct pbuf *p, struct tcp_hdr *hdr, const struct tcp_pcb *pcb, u32_t *opts)
{
LWIP_ASSERT("p != NULL", p != NULL);
LWIP_ASSERT("hdr != NULL", hdr != NULL);
LWIP_ASSERT("pcb != NULL", pcb != NULL);
LWIP_ASSERT("opts != NULL", opts != NULL);
if (tcp_md5_is_enabled_on_pcb(pcb)) {
u8_t digest_calculated[LWIP_TCP_MD5_DIGEST_LEN];
u32_t *opts_ret = opts + 5; /* we use 20 bytes: 2 bytes padding + 18 bytes for this option */
u8_t *ptr = (u8_t*)opts;
const struct tcp_md5_conn_info *info = tcp_md5_get_info(pcb, &pcb->remote_ip, pcb->remote_port);
if (info != NULL) {
struct tcp_hdr hdr_copy;
size_t hdrsize = TCPH_HDRLEN_BYTES(hdr);
tcp_md5_dup_tcphdr(&hdr_copy, hdr, 0);
/* p->payload points to the tcp header */
LWIP_ASSERT("p->payload == hdr", p->payload == hdr);
if (!pbuf_remove_header(p, hdrsize)) {
u8_t ret;
if (!tcp_md5_create_digest(&pcb->local_ip, &pcb->remote_ip, &hdr_copy, info->key, info->key_len, digest_calculated, p)) {
info = NULL;
}
ret = pbuf_add_header_force(p, hdrsize);
LWIP_ASSERT("tcp_md5_add_tx_options: pbuf_add_header_force failed", !ret);
LWIP_UNUSED_ARG(ret);
} else {
LWIP_ASSERT("error", 0);
}
}
if (info == NULL) {
/* create an invalid signature by zeroing the digest */
memset(&digest_calculated, 0, sizeof(digest_calculated));
}
*ptr++ = LWIP_TCP_OPT_NOP;
*ptr++ = LWIP_TCP_OPT_NOP;
*ptr++ = LWIP_TCP_OPT_MD5;
*ptr++ = LWIP_TCP_OPT_LEN_MD5;
memcpy(ptr, digest_calculated, LWIP_TCP_MD5_DIGEST_LEN);
ptr += LWIP_TCP_MD5_DIGEST_LEN;
LWIP_ASSERT("ptr == opts_ret", ptr == (u8_t *)opts_ret);
return opts_ret;
}
return opts;
}
/* Hook implementation for LWIP_HOOK_SOCKETS_SETSOCKOPT */
int
tcp_md5_setsockopt_hook(struct lwip_sock *sock, int level, int optname, const void *optval, socklen_t optlen, int *err)
{
LWIP_ASSERT("sock != NULL", sock != NULL);
LWIP_ASSERT("err != NULL", err != NULL);
if ((level == IPPROTO_TCP) && (optname == TCP_MD5SIG)) {
const struct tcp_md5sig *md5 = (const struct tcp_md5sig*)optval;
if ((optval == NULL) || (optlen < sizeof(struct tcp_md5sig))) {
*err = EINVAL;
} else {
if (sock->conn && (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP) && (sock->conn->pcb.tcp != NULL)) {
if (tcp_md5_extarg_id == LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID) {
/* not initialized */
*err = EINVAL;
} else {
struct tcp_md5_conn_info *info = tcp_md5_conn_info_alloc();
if (info == NULL) {
*err = ENOMEM;
} else {
int addr_valid = 0;
/* OK, fill and link this request */
memcpy(info->key, md5->tcpm_key, TCP_MD5SIG_MAXKEYLEN);
info->key_len = md5->tcpm_keylen;
memset(&info->remote_addr, 0, sizeof(info->remote_addr));
if (md5->tcpm_addr.ss_family == AF_INET) {
#if LWIP_IPV4
const struct sockaddr_in *sin = (const struct sockaddr_in *)&md5->tcpm_addr;
memcpy(&info->remote_addr, &sin->sin_addr, sizeof(sin->sin_addr));
IP_SET_TYPE_VAL(info->remote_addr, IPADDR_TYPE_V4);
info->remote_port = lwip_htons(sin->sin_port);
addr_valid = 1;
#endif /* LWIP_IPV4 */
} else if (md5->tcpm_addr.ss_family == AF_INET6) {
#if LWIP_IPV6
const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)&md5->tcpm_addr;
memcpy(&info->remote_addr, &sin6->sin6_addr, sizeof(sin6->sin6_addr));
IP_SET_TYPE_VAL(info->remote_addr, IPADDR_TYPE_V6);
info->remote_port = lwip_htons(sin6->sin6_port);
addr_valid = 1;
#endif /* LWIP_IPV6 */
}
if (addr_valid) {
/* store it */
tcp_ext_arg_set_callbacks(sock->conn->pcb.tcp, tcp_md5_extarg_id, &tcp_md5_ext_arg_callbacks);
info->next = (struct tcp_md5_conn_info *)tcp_ext_arg_get(sock->conn->pcb.tcp, tcp_md5_extarg_id);
tcp_ext_arg_set(sock->conn->pcb.tcp, tcp_md5_extarg_id, info);
} else {
*err = EINVAL;
tcp_md5_conn_info_free(info);
}
}
}
} else {
/* not a tcp netconn */
*err = EINVAL;
}
}
return 1;
}
return 0;
}

View File

@@ -1,84 +0,0 @@
/*
* Copyright (c) 2018 Simon Goldschmidt
* 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.
*
* Author: Simon Goldschmidt <goldsimon@gmx.de>
*
* To use the hooks in this file, make sure this file is included in LWIP_HOOK_FILENAME
* and define these hooks:
*
* #define LWIP_HOOK_TCP_INPACKET_PCB(pcb, hdr, optlen, opt1len, opt2, p) tcp_md5_check_inpacket(pcb, hdr, optlen, opt1len, opt2, p)
* #define LWIP_HOOK_TCP_OPT_LENGTH_SEGMENT(pcb, internal_len) tcp_md5_get_additional_option_length(pcb, internal_len)
* #define LWIP_HOOK_TCP_ADD_TX_OPTIONS(p, hdr, pcb, opts) tcp_md5_add_tx_options(p, hdr, pcb, opts)
*
* #define LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) tcp_md5_setsockopt_hook(sock, level, optname, optval, optlen, err)
*/
#ifndef LWIP_HDR_CONTRIB_ADDONS_TCP_MD5_H
#define LWIP_HDR_CONTRIB_ADDONS_TCP_MD5_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/priv/sockets_priv.h"
#include "lwip/priv/tcp_priv.h"
#ifdef __cplusplus
extern "C" {
#endif
/* setsockopt definitions and structs: */
/* This is the optname (for level = IPPROTO_TCP) */
#ifndef TCP_MD5SIG
#define TCP_MD5SIG 14
#endif
#define TCP_MD5SIG_MAXKEYLEN 80
/* This is the optval type */
struct tcp_md5sig {
struct sockaddr_storage tcpm_addr;
u16_t __tcpm_pad1;
u16_t tcpm_keylen;
u32_t __tcpm_pad2;
u8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
};
/* socket setsockopt hook: */
int tcp_md5_setsockopt_hook(struct lwip_sock *sock, int level, int optname, const void *optval, u32_t optlen, int *err);
/* Internal hook functions */
void tcp_md5_init(void);
err_t tcp_md5_check_inpacket(struct tcp_pcb* pcb, struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2, struct pbuf *p);
u8_t tcp_md5_get_additional_option_length(const struct tcp_pcb *pcb, u8_t internal_option_length);
u32_t *tcp_md5_add_tx_options(struct pbuf *p, struct tcp_hdr *hdr, const struct tcp_pcb *pcb, u32_t *opts);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_HDR_CONTRIB_ADDONS_TCP_MD5_H */

View File

@@ -1 +0,0 @@
See docs in src/apps/snmp/snmp_core.c.

View File

@@ -1,52 +0,0 @@
CHARGEN
This file implements a nice example of handling multiple tcp sockets in a
server environment. Just call chargen_init() from your application after
you have initialized lwip and added your network interfaces. Change the
MAX_SERV option to increase or decrease the number of sessions supported.
chargen will jam as much data as possible into the output socket, so it
will take up a lot of CPU time. Therefore it will be a good idea to run it
as the lowest possible priority (just ahead of any idle task).
This is also a good example of how to support multiple sessions in an
embedded system where you might not have fork(). The multiple sessions are
all handled by the same thread and select() is used for demultiplexing.
No makefile is provided, just add chargen to the makefile for your
application. It is OS and HW independent.
Once the chargen server is running in your application, go to another system
and open a telnet session to your lwip platform at port 19. You should see an
ASCII pattern start to stream on you screen.
As an example, lets say that your system running lwip is at IP address
192.168.10.244 and you have a linux system connected to it at IP address
192.168.10.59. Issue the following command at a terminal prompt on the linux system:
telnet 192.168.10.244 19
You will see a pattern similar to the following on streaming by on your
screen:
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{
BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|
CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!
FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"
GHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#
HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$
IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%
JKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&
KLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'
LMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'(
It even works from windows: At a dos prompt you can also issue the same
telnet command and you will get a similar (but much slower, at least on W98)
data stream.
David Haas

View File

@@ -1,274 +0,0 @@
/** @file
*
* chargen server for lwip
*/
/*
* Copyright (c) 2003 NBS Card Technology, Paramus, NJ.
* 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: David Haas <dhaas@alum.rpi.edu>
*
* Purpose: chargen server for testing and demonstration purposes
*
* This file implements a nice example of handling multiple tcp sockets in a
* server environment. Just call chargen_init() from your application after
* you have initialized lwip and added your network interfaces. Change the
* MAX_SERV option to increase or decrease the number of sessions supported.
*
* chargen will jam as much data as possible into the output socket, so it
* will take up a lot of CPU time. Therefore it will be a good idea to run it
* as the lowest possible priority (just ahead of any idle task).
*
* This is also a good example of how to support multiple sessions in an
* embedded system where you might not have fork().
*/
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "lwip/sockets.h"
#include "lwip/mem.h"
#include <string.h>
#include "chargen.h"
#if LWIP_SOCKET && LWIP_SOCKET_SELECT
#define MAX_SERV 5 /* Maximum number of chargen services. Don't need too many */
#define CHARGEN_THREAD_NAME "chargen"
#define CHARGEN_PRIORITY 254 /* Really low priority */
#define CHARGEN_THREAD_STACKSIZE 0
#define SEND_SIZE TCP_SNDLOWAT /* If we only send this much, then when select
says we can send, we know we won't block */
struct charcb {
struct charcb *next;
int socket;
struct sockaddr_storage cliaddr;
socklen_t clilen;
char nextchar;
};
static struct charcb *charcb_list = NULL;
/**************************************************************
* void close_chargen(struct charcb *p_charcb)
*
* Close the socket and remove this charcb from the list.
**************************************************************/
static void
close_chargen(struct charcb *p_charcb)
{
struct charcb *p_search_charcb;
/* Either an error or tcp connection closed on other
* end. Close here */
lwip_close(p_charcb->socket);
/* Free charcb */
if (charcb_list == p_charcb) {
charcb_list = p_charcb->next;
} else {
for (p_search_charcb = charcb_list; p_search_charcb; p_search_charcb = p_search_charcb->next) {
if (p_search_charcb->next == p_charcb) {
p_search_charcb->next = p_charcb->next;
break;
}
}
}
mem_free(p_charcb);
}
/**************************************************************
* void do_read(struct charcb *p_charcb)
*
* Socket definitely is ready for reading. Read a buffer from the socket and
* discard the data. If no data is read, then the socket is closed and the
* charcb is removed from the list and freed.
**************************************************************/
static int
do_read(struct charcb *p_charcb)
{
char buffer[80];
int readcount;
/* Read some data */
readcount = lwip_read(p_charcb->socket, &buffer, 80);
if (readcount <= 0) {
close_chargen(p_charcb);
return -1;
}
return 0;
}
/**************************************************************
* void chargen_thread(void *arg)
*
* chargen task. This server will wait for connections on well
* known TCP port number: 19. For every connection, the server will
* write as much data as possible to the tcp port.
**************************************************************/
static void
chargen_thread(void *arg)
{
int listenfd;
#if LWIP_IPV6
struct sockaddr_in6 chargen_saddr;
#else /* LWIP_IPV6 */
struct sockaddr_in chargen_saddr;
#endif /* LWIP_IPV6 */
fd_set readset;
fd_set writeset;
int i, maxfdp1;
struct charcb *p_charcb;
LWIP_UNUSED_ARG(arg);
memset(&chargen_saddr, 0, sizeof (chargen_saddr));
#if LWIP_IPV6
/* First acquire our socket for listening for connections */
listenfd = lwip_socket(AF_INET6, SOCK_STREAM, 0);
chargen_saddr.sin6_family = AF_INET6;
chargen_saddr.sin6_addr = in6addr_any;
chargen_saddr.sin6_port = lwip_htons(19); /* Chargen server port */
#else /* LWIP_IPV6 */
/* First acquire our socket for listening for connections */
listenfd = lwip_socket(AF_INET, SOCK_STREAM, 0);
chargen_saddr.sin_family = AF_INET;
chargen_saddr.sin_addr.s_addr = PP_HTONL(INADDR_ANY);
chargen_saddr.sin_port = lwip_htons(19); /* Chargen server port */
#endif /* LWIP_IPV6 */
LWIP_ASSERT("chargen_thread(): Socket create failed.", listenfd >= 0);
if (lwip_bind(listenfd, (struct sockaddr *) &chargen_saddr, sizeof (chargen_saddr)) == -1) {
LWIP_ASSERT("chargen_thread(): Socket bind failed.", 0);
}
/* Put socket into listening mode */
if (lwip_listen(listenfd, MAX_SERV) == -1) {
LWIP_ASSERT("chargen_thread(): Listen failed.", 0);
}
/* Wait forever for network input: This could be connections or data */
for (;;) {
maxfdp1 = listenfd + 1;
/* Determine what sockets need to be in readset */
FD_ZERO(&readset);
FD_ZERO(&writeset);
FD_SET(listenfd, &readset);
for (p_charcb = charcb_list; p_charcb; p_charcb = p_charcb->next) {
if (maxfdp1 < p_charcb->socket + 1) {
maxfdp1 = p_charcb->socket + 1;
}
FD_SET(p_charcb->socket, &readset);
FD_SET(p_charcb->socket, &writeset);
}
/* Wait for data or a new connection */
i = lwip_select(maxfdp1, &readset, &writeset, NULL, NULL);
if (i == 0) {
continue;
}
/* At least one descriptor is ready */
if (FD_ISSET(listenfd, &readset)) {
/* We have a new connection request!!! */
/* Lets create a new control block */
p_charcb = (struct charcb *) mem_malloc(sizeof (struct charcb));
if (p_charcb) {
p_charcb->socket = lwip_accept(listenfd,
(struct sockaddr *) &p_charcb->cliaddr,
&p_charcb->clilen);
if (p_charcb->socket < 0) {
mem_free(p_charcb);
} else {
/* Keep this tecb in our list */
p_charcb->next = charcb_list;
charcb_list = p_charcb;
p_charcb->nextchar = 0x21;
}
} else {
/* No memory to accept connection. Just accept and then close */
int sock;
struct sockaddr cliaddr;
socklen_t clilen;
sock = lwip_accept(listenfd, &cliaddr, &clilen);
if (sock >= 0) {
lwip_close(sock);
}
}
}
/* Go through list of connected clients and process data */
for (p_charcb = charcb_list; p_charcb; p_charcb = p_charcb->next) {
if (FD_ISSET(p_charcb->socket, &readset)) {
/* This socket is ready for reading. This could be because someone typed
* some characters or it could be because the socket is now closed. Try reading
* some data to see. */
if (do_read(p_charcb) < 0) {
break;
}
}
if (FD_ISSET(p_charcb->socket, &writeset)) {
char line[80];
char setchar = p_charcb->nextchar;
for (i = 0; i < 59; i++) {
line[i] = setchar;
if (++setchar == 0x7f) {
setchar = 0x21;
}
}
line[i] = 0;
strcat(line, "\n\r");
if (lwip_write(p_charcb->socket, line, strlen(line)) < 0) {
close_chargen(p_charcb);
break;
}
if (++p_charcb->nextchar == 0x7f) {
p_charcb->nextchar = 0x21;
}
}
}
}
}
/**************************************************************
* void chargen_init(void)
*
* This function initializes the chargen service. This function
* may only be called either before or after tasking has started.
**************************************************************/
void
chargen_init(void)
{
sys_thread_new(CHARGEN_THREAD_NAME, chargen_thread, NULL, CHARGEN_THREAD_STACKSIZE, CHARGEN_PRIORITY);
}
#endif /* LWIP_SOCKET && LWIP_SOCKET_SELECT */

View File

@@ -1,12 +0,0 @@
#ifndef LWIP_CHARGEN_H
#define LWIP_CHARGEN_H
#include "lwip/opt.h"
#if LWIP_SOCKET
void chargen_init(void);
#endif /* LWIP_SOCKET */
#endif /* LWIP_CHARGEN_H */

View File

@@ -1,12 +0,0 @@
HTTPSERVER
This is a demonstration of how to make the most basic kind
of server using lWIP.
* httpserver-raw.c - uses raw TCP calls (coming soon!)
* httpserver-netconn.c - uses netconn and netbuf API
This code updates the examples in Adam Dunkel's original
lwIP documentation to match changes in the code since that
PDF release.

View File

@@ -1,103 +0,0 @@
#include "lwip/opt.h"
#include "lwip/arch.h"
#include "lwip/api.h"
#include "httpserver-netconn.h"
#if LWIP_NETCONN
#ifndef HTTPD_DEBUG
#define HTTPD_DEBUG LWIP_DBG_OFF
#endif
static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
static const char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page, served by httpserver-netconn.</body></html>";
/** Serve one HTTP connection accepted in the http thread */
static void
http_server_netconn_serve(struct netconn *conn)
{
struct netbuf *inbuf;
char *buf;
u16_t buflen;
err_t err;
/* Read the data from the port, blocking if nothing yet there.
We assume the request (the part we care about) is in one netbuf */
err = netconn_recv(conn, &inbuf);
if (err == ERR_OK) {
netbuf_data(inbuf, (void**)&buf, &buflen);
/* Is this an HTTP GET command? (only check the first 5 chars, since
there are other formats for GET, and we're keeping it very simple )*/
if (buflen>=5 &&
buf[0]=='G' &&
buf[1]=='E' &&
buf[2]=='T' &&
buf[3]==' ' &&
buf[4]=='/' ) {
/* Send the HTML header
* subtract 1 from the size, since we don't send the \0 in the string
* NETCONN_NOCOPY: our data is const static, so no need to copy it
*/
netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
/* Send our HTML page */
netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
}
}
/* Close the connection (server closes in HTTP) */
netconn_close(conn);
/* Delete the buffer (netconn_recv gives us ownership,
so we have to make sure to deallocate the buffer) */
netbuf_delete(inbuf);
}
/** The main function, never returns! */
static void
http_server_netconn_thread(void *arg)
{
struct netconn *conn, *newconn;
err_t err;
LWIP_UNUSED_ARG(arg);
/* Create a new TCP connection handle */
/* Bind to port 80 (HTTP) with default IP address */
#if LWIP_IPV6
conn = netconn_new(NETCONN_TCP_IPV6);
netconn_bind(conn, IP6_ADDR_ANY, 80);
#else /* LWIP_IPV6 */
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, IP_ADDR_ANY, 80);
#endif /* LWIP_IPV6 */
LWIP_ERROR("http_server: invalid conn", (conn != NULL), return;);
/* Put the connection into LISTEN state */
netconn_listen(conn);
do {
err = netconn_accept(conn, &newconn);
if (err == ERR_OK) {
http_server_netconn_serve(newconn);
netconn_delete(newconn);
}
} while(err == ERR_OK);
LWIP_DEBUGF(HTTPD_DEBUG,
("http_server_netconn_thread: netconn_accept received error %d, shutting down\n",
err));
netconn_close(conn);
netconn_delete(conn);
}
/** Initialize the HTTP server (start its thread) */
void
http_server_netconn_init(void)
{
sys_thread_new("http_server_netconn", http_server_netconn_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
#endif /* LWIP_NETCONN*/

View File

@@ -1,6 +0,0 @@
#ifndef LWIP_HTTPSERVER_NETCONN_H
#define LWIP_HTTPSERVER_NETCONN_H
void http_server_netconn_init(void);
#endif /* LWIP_HTTPSERVER_NETCONN_H */

View File

@@ -1,55 +0,0 @@
#include "netio.h"
#include "lwip/opt.h"
#include "lwip/tcp.h"
/* See http://www.nwlab.net/art/netio/netio.html to get the netio tool */
#if LWIP_TCP && LWIP_CALLBACK_API
static err_t
netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
LWIP_UNUSED_ARG(arg);
if (err == ERR_OK && p != NULL) {
tcp_recved(pcb, p->tot_len);
pbuf_free(p);
} else {
pbuf_free(p);
}
if (err == ERR_OK && p == NULL) {
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_close(pcb);
}
return ERR_OK;
}
static err_t
netio_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);
if (pcb != NULL) {
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, netio_recv);
}
return ERR_OK;
}
void
netio_init(void)
{
struct tcp_pcb *pcb;
pcb = tcp_new_ip_type(IPADDR_TYPE_ANY);
tcp_bind(pcb, IP_ANY_TYPE, 18767);
pcb = tcp_listen(pcb);
tcp_accept(pcb, netio_accept);
}
#endif /* LWIP_TCP && LWIP_CALLBACK_API */

View File

@@ -1,6 +0,0 @@
#ifndef LWIP_NETIO_H
#define LWIP_NETIO_H
void netio_init(void);
#endif /* LWIP_NETIO_H */

View File

@@ -1,428 +0,0 @@
/**
* @file
* Ping sender module
*
*/
/*
* 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.
*
*/
/**
* This is an example of a "ping" sender (with raw API and socket API).
* It can be used as a start point to maintain opened a network connection, or
* like a network "watchdog" for your device.
*
*/
#include "lwip/opt.h"
#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
#include "ping.h"
#include "lwip/mem.h"
#include "lwip/raw.h"
#include "lwip/icmp.h"
#include "lwip/netif.h"
#include "lwip/sys.h"
#include "lwip/timeouts.h"
#include "lwip/inet_chksum.h"
#include "lwip/prot/ip4.h"
#if PING_USE_SOCKETS
#include "lwip/sockets.h"
#include "lwip/inet.h"
#include <string.h>
#endif /* PING_USE_SOCKETS */
/**
* PING_DEBUG: Enable debugging for PING.
*/
#ifndef PING_DEBUG
#define PING_DEBUG LWIP_DBG_ON
#endif
/** ping receive timeout - in milliseconds */
#ifndef PING_RCV_TIMEO
#define PING_RCV_TIMEO 1000
#endif
/** ping delay - in milliseconds */
#ifndef PING_DELAY
#define PING_DELAY 1000
#endif
/** ping identifier - must fit on a u16_t */
#ifndef PING_ID
#define PING_ID 0xAFAF
#endif
/** ping additional data size to include in the packet */
#ifndef PING_DATA_SIZE
#define PING_DATA_SIZE 32
#endif
/** ping result action - no default action */
#ifndef PING_RESULT
#define PING_RESULT(ping_ok)
#endif
/* ping variables */
static const ip_addr_t* ping_target;
static u16_t ping_seq_num;
#ifdef LWIP_DEBUG
static u32_t ping_time;
#endif /* LWIP_DEBUG */
#if !PING_USE_SOCKETS
static struct raw_pcb *ping_pcb;
#endif /* PING_USE_SOCKETS */
/** Prepare a echo ICMP request */
static void
ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
{
size_t i;
size_t data_len = len - sizeof(struct icmp_echo_hdr);
ICMPH_TYPE_SET(iecho, ICMP_ECHO);
ICMPH_CODE_SET(iecho, 0);
iecho->chksum = 0;
iecho->id = PING_ID;
iecho->seqno = lwip_htons(++ping_seq_num);
/* fill the additional data buffer with some data */
for(i = 0; i < data_len; i++) {
((char*)iecho)[sizeof(struct icmp_echo_hdr) + i] = (char)i;
}
iecho->chksum = inet_chksum(iecho, len);
}
#if PING_USE_SOCKETS
/* Ping using the socket ip */
static err_t
ping_send(int s, const ip_addr_t *addr)
{
int err;
struct icmp_echo_hdr *iecho;
struct sockaddr_storage to;
size_t ping_size = sizeof(struct icmp_echo_hdr) + PING_DATA_SIZE;
LWIP_ASSERT("ping_size is too big", ping_size <= 0xffff);
#if LWIP_IPV6
if(IP_IS_V6(addr) && !ip6_addr_isipv4mappedipv6(ip_2_ip6(addr))) {
/* todo: support ICMP6 echo */
return ERR_VAL;
}
#endif /* LWIP_IPV6 */
iecho = (struct icmp_echo_hdr *)mem_malloc((mem_size_t)ping_size);
if (!iecho) {
return ERR_MEM;
}
ping_prepare_echo(iecho, (u16_t)ping_size);
#if LWIP_IPV4
if(IP_IS_V4(addr)) {
struct sockaddr_in *to4 = (struct sockaddr_in*)&to;
to4->sin_len = sizeof(*to4);
to4->sin_family = AF_INET;
inet_addr_from_ip4addr(&to4->sin_addr, ip_2_ip4(addr));
}
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
if(IP_IS_V6(addr)) {
struct sockaddr_in6 *to6 = (struct sockaddr_in6*)&to;
to6->sin6_len = sizeof(*to6);
to6->sin6_family = AF_INET6;
inet6_addr_from_ip6addr(&to6->sin6_addr, ip_2_ip6(addr));
}
#endif /* LWIP_IPV6 */
err = lwip_sendto(s, iecho, ping_size, 0, (struct sockaddr*)&to, sizeof(to));
mem_free(iecho);
return (err ? ERR_OK : ERR_VAL);
}
static void
ping_recv(int s)
{
char buf[64];
int len;
struct sockaddr_storage from;
int fromlen = sizeof(from);
while((len = lwip_recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0) {
if (len >= (int)(sizeof(struct ip_hdr)+sizeof(struct icmp_echo_hdr))) {
ip_addr_t fromaddr;
memset(&fromaddr, 0, sizeof(fromaddr));
#if LWIP_IPV4
if(from.ss_family == AF_INET) {
struct sockaddr_in *from4 = (struct sockaddr_in*)&from;
inet_addr_to_ip4addr(ip_2_ip4(&fromaddr), &from4->sin_addr);
IP_SET_TYPE_VAL(fromaddr, IPADDR_TYPE_V4);
}
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
if(from.ss_family == AF_INET6) {
struct sockaddr_in6 *from6 = (struct sockaddr_in6*)&from;
inet6_addr_to_ip6addr(ip_2_ip6(&fromaddr), &from6->sin6_addr);
IP_SET_TYPE_VAL(fromaddr, IPADDR_TYPE_V6);
}
#endif /* LWIP_IPV6 */
LWIP_DEBUGF( PING_DEBUG, ("ping: recv "));
ip_addr_debug_print_val(PING_DEBUG, fromaddr);
LWIP_DEBUGF( PING_DEBUG, (" %"U32_F" ms\n", (sys_now() - ping_time)));
/* todo: support ICMP6 echo */
#if LWIP_IPV4
if (IP_IS_V4_VAL(fromaddr)) {
struct ip_hdr *iphdr;
struct icmp_echo_hdr *iecho;
iphdr = (struct ip_hdr *)buf;
iecho = (struct icmp_echo_hdr *)(buf + (IPH_HL(iphdr) * 4));
if ((iecho->id == PING_ID) && (iecho->seqno == lwip_htons(ping_seq_num))) {
/* do some ping result processing */
PING_RESULT((ICMPH_TYPE(iecho) == ICMP_ER));
return;
} else {
LWIP_DEBUGF( PING_DEBUG, ("ping: drop\n"));
}
}
#endif /* LWIP_IPV4 */
}
fromlen = sizeof(from);
}
if (len == 0) {
LWIP_DEBUGF( PING_DEBUG, ("ping: recv - %"U32_F" ms - timeout\n", (sys_now()-ping_time)));
}
/* do some ping result processing */
PING_RESULT(0);
}
static void
ping_thread(void *arg)
{
int s;
int ret;
#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
int timeout = PING_RCV_TIMEO;
#else
struct timeval timeout;
timeout.tv_sec = PING_RCV_TIMEO/1000;
timeout.tv_usec = (PING_RCV_TIMEO%1000)*1000;
#endif
LWIP_UNUSED_ARG(arg);
#if LWIP_IPV6
if(IP_IS_V4(ping_target) || ip6_addr_isipv4mappedipv6(ip_2_ip6(ping_target))) {
s = lwip_socket(AF_INET6, SOCK_RAW, IP_PROTO_ICMP);
} else {
s = lwip_socket(AF_INET6, SOCK_RAW, IP6_NEXTH_ICMP6);
}
#else
s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP);
#endif
if (s < 0) {
return;
}
ret = lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
LWIP_ASSERT("setting receive timeout failed", ret == 0);
LWIP_UNUSED_ARG(ret);
while (ping_target != NULL) {
if (ping_send(s, ping_target) == ERR_OK) {
LWIP_DEBUGF( PING_DEBUG, ("ping: send "));
ip_addr_debug_print(PING_DEBUG, ping_target);
LWIP_DEBUGF( PING_DEBUG, ("\n"));
#ifdef LWIP_DEBUG
ping_time = sys_now();
#endif /* LWIP_DEBUG */
ping_recv(s);
} else {
LWIP_DEBUGF( PING_DEBUG, ("ping: send "));
ip_addr_debug_print(PING_DEBUG, ping_target);
LWIP_DEBUGF( PING_DEBUG, (" - error\n"));
}
sys_msleep(PING_DELAY);
}
lwip_close(s);
}
#else /* PING_USE_SOCKETS */
/* Ping using the raw ip */
static u8_t
ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
{
struct icmp_echo_hdr *iecho;
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(pcb);
LWIP_UNUSED_ARG(addr);
LWIP_ASSERT("addr != NULL", addr != NULL);
LWIP_ASSERT("p != NULL", p != NULL);
if ((p->tot_len >= (IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
pbuf_remove_header(p, IP_HLEN) == 0) {
iecho = (struct icmp_echo_hdr *)p->payload;
if ((iecho->id == PING_ID) && (iecho->seqno == lwip_htons(ping_seq_num))) {
LWIP_DEBUGF( PING_DEBUG, ("ping: recv "));
ip_addr_debug_print(PING_DEBUG, addr);
LWIP_DEBUGF( PING_DEBUG, (" %"U32_F" ms\n", (sys_now()-ping_time)));
/* do some ping result processing */
PING_RESULT(1);
pbuf_free(p);
return 1; /* eat the packet */
}
/* not eaten, restore original packet */
pbuf_add_header(p, IP_HLEN);
}
return 0; /* don't eat the packet */
}
static void
ping_send(struct raw_pcb *raw, const ip_addr_t *addr)
{
struct pbuf *p;
struct icmp_echo_hdr *iecho;
size_t ping_size = sizeof(struct icmp_echo_hdr) + PING_DATA_SIZE;
LWIP_DEBUGF( PING_DEBUG, ("ping: send "));
ip_addr_debug_print(PING_DEBUG, addr);
LWIP_DEBUGF( PING_DEBUG, ("\n"));
LWIP_ASSERT("ping_size <= 0xffff", ping_size <= 0xffff);
p = pbuf_alloc(PBUF_IP, (u16_t)ping_size, PBUF_RAM);
if (!p) {
return;
}
if ((p->len == p->tot_len) && (p->next == NULL)) {
iecho = (struct icmp_echo_hdr *)p->payload;
ping_prepare_echo(iecho, (u16_t)ping_size);
raw_sendto(raw, p, addr);
#ifdef LWIP_DEBUG
ping_time = sys_now();
#endif /* LWIP_DEBUG */
}
pbuf_free(p);
}
static void
ping_timeout(void *arg)
{
struct raw_pcb *pcb = (struct raw_pcb*)arg;
LWIP_ASSERT("ping_timeout: no pcb given!", pcb != NULL);
ping_send(pcb, ping_target);
sys_timeout(PING_DELAY, ping_timeout, pcb);
}
static void
ping_raw_init(void)
{
ping_pcb = raw_new(IP_PROTO_ICMP);
LWIP_ASSERT("ping_pcb != NULL", ping_pcb != NULL);
raw_recv(ping_pcb, ping_recv, NULL);
raw_bind(ping_pcb, IP_ADDR_ANY);
sys_timeout(PING_DELAY, ping_timeout, ping_pcb);
}
void
ping_send_now(void)
{
LWIP_ASSERT("ping_pcb != NULL", ping_pcb != NULL);
LWIP_ASSERT("ping_target != NULL", ping_target != NULL);
ping_send(ping_pcb, ping_target);
}
static void
ping_raw_stop(void)
{
sys_untimeout(ping_timeout, ping_pcb);
if (ping_pcb != NULL) {
raw_remove(ping_pcb);
ping_pcb = NULL;
}
}
#endif /* PING_USE_SOCKETS */
/**
* Initialize thread (socket mode) or timer (callback mode) to cyclically send pings
* to a target.
* Running ping is implicitly stopped.
*/
void
ping_init(const ip_addr_t* ping_addr)
{
ping_stop();
LWIP_ASSERT("ping_addr != NULL", ping_addr != NULL);
ping_target = ping_addr;
#if PING_USE_SOCKETS
sys_thread_new("ping_thread", ping_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
#else /* PING_USE_SOCKETS */
ping_raw_init();
#endif /* PING_USE_SOCKETS */
}
/**
* Stop sending more pings.
*/
void ping_stop(void)
{
#if !PING_USE_SOCKETS
ping_raw_stop();
#endif /* !PING_USE_SOCKETS */
ping_target = NULL;
}
#endif /* LWIP_RAW */

View File

@@ -1,20 +0,0 @@
#ifndef LWIP_PING_H
#define LWIP_PING_H
#include "lwip/ip_addr.h"
/**
* PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used
*/
#ifndef PING_USE_SOCKETS
#define PING_USE_SOCKETS LWIP_SOCKET
#endif
void ping_init(const ip_addr_t* ping_addr);
void ping_stop(void);
#if !PING_USE_SOCKETS
void ping_send_now(void);
#endif /* !PING_USE_SOCKETS */
#endif /* LWIP_PING_H */

View File

@@ -1,308 +0,0 @@
/**
* @file
* RTP client/server module
*
*/
/*
* 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.
*
*/
#include "lwip/opt.h"
#if LWIP_SOCKET && LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
#include "lwip/sys.h"
#include "lwip/sockets.h"
#include "rtp.h"
#include "rtpdata.h"
#include <string.h>
/** This is an example of a "RTP" client/server based on a MPEG4 bitstream (with socket API).
*/
/**
* RTP_DEBUG: Enable debugging for RTP.
*/
#ifndef RTP_DEBUG
#define RTP_DEBUG LWIP_DBG_ON
#endif
/** RTP stream port */
#ifndef RTP_STREAM_PORT
#define RTP_STREAM_PORT 4000
#endif
/** RTP stream multicast address as IPv4 address in "u32_t" format */
#ifndef RTP_STREAM_ADDRESS
#define RTP_STREAM_ADDRESS inet_addr("232.0.0.0")
#endif
/** RTP send delay - in milliseconds */
#ifndef RTP_SEND_DELAY
#define RTP_SEND_DELAY 40
#endif
/** RTP receive timeout - in milliseconds */
#ifndef RTP_RECV_TIMEOUT
#define RTP_RECV_TIMEOUT 2000
#endif
/** RTP stats display period - in received packets */
#ifndef RTP_RECV_STATS
#define RTP_RECV_STATS 50
#endif
/** RTP macro to let the application process the data */
#ifndef RTP_RECV_PROCESSING
#define RTP_RECV_PROCESSING(p,s)
#endif
/** RTP packet/payload size */
#define RTP_PACKET_SIZE 1500
#define RTP_PAYLOAD_SIZE 1024
/** RTP header constants */
#define RTP_VERSION 0x80
#define RTP_TIMESTAMP_INCREMENT 3600
#define RTP_SSRC 0
#define RTP_PAYLOADTYPE 96
#define RTP_MARKER_MASK 0x80
/** RTP message header */
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
struct rtp_hdr {
PACK_STRUCT_FLD_8(u8_t version);
PACK_STRUCT_FLD_8(u8_t payloadtype);
PACK_STRUCT_FIELD(u16_t seqNum);
PACK_STRUCT_FIELD(u32_t timestamp);
PACK_STRUCT_FIELD(u32_t ssrc);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
/** RTP packets */
static u8_t rtp_send_packet[RTP_PACKET_SIZE];
static u8_t rtp_recv_packet[RTP_PACKET_SIZE];
/**
* RTP send packets
*/
static void
rtp_send_packets( int sock, struct sockaddr_in* to)
{
struct rtp_hdr* rtphdr;
u8_t* rtp_payload;
size_t rtp_payload_size;
size_t rtp_data_index;
/* prepare RTP packet */
rtphdr = (struct rtp_hdr*)rtp_send_packet;
rtphdr->version = RTP_VERSION;
rtphdr->payloadtype = 0;
rtphdr->ssrc = PP_HTONL(RTP_SSRC);
rtphdr->timestamp = lwip_htonl(lwip_ntohl(rtphdr->timestamp) + RTP_TIMESTAMP_INCREMENT);
/* send RTP stream packets */
rtp_data_index = 0;
do {
rtp_payload = rtp_send_packet+sizeof(struct rtp_hdr);
rtp_payload_size = LWIP_MIN(RTP_PAYLOAD_SIZE, sizeof(rtp_data) - rtp_data_index);
MEMCPY(rtp_payload, rtp_data + rtp_data_index, rtp_payload_size);
/* set MARKER bit in RTP header on the last packet of an image */
if ((rtp_data_index + rtp_payload_size) >= sizeof(rtp_data)) {
rtphdr->payloadtype = RTP_PAYLOADTYPE | RTP_MARKER_MASK;
} else {
rtphdr->payloadtype = RTP_PAYLOADTYPE;
}
/* send RTP stream packet */
if (lwip_sendto(sock, rtp_send_packet, sizeof(struct rtp_hdr) + rtp_payload_size,
0, (struct sockaddr *)to, sizeof(struct sockaddr)) >= 0) {
rtphdr->seqNum = lwip_htons((u16_t)(lwip_ntohs(rtphdr->seqNum) + 1));
rtp_data_index += rtp_payload_size;
} else {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_sender: not sendto==%i\n", errno));
}
}while (rtp_data_index < sizeof(rtp_data));
}
/**
* RTP send thread
*/
static void
rtp_send_thread(void *arg)
{
int sock;
struct sockaddr_in local;
struct sockaddr_in to;
u32_t rtp_stream_address;
LWIP_UNUSED_ARG(arg);
/* initialize RTP stream address */
rtp_stream_address = RTP_STREAM_ADDRESS;
/* if we got a valid RTP stream address... */
if (rtp_stream_address != 0) {
/* create new socket */
sock = lwip_socket(AF_INET, SOCK_DGRAM, 0);
if (sock >= 0) {
/* prepare local address */
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_port = PP_HTONS(INADDR_ANY);
local.sin_addr.s_addr = PP_HTONL(INADDR_ANY);
/* bind to local address */
if (lwip_bind(sock, (struct sockaddr *)&local, sizeof(local)) == 0) {
/* prepare RTP stream address */
memset(&to, 0, sizeof(to));
to.sin_family = AF_INET;
to.sin_port = PP_HTONS(RTP_STREAM_PORT);
to.sin_addr.s_addr = rtp_stream_address;
/* send RTP packets */
memset(rtp_send_packet, 0, sizeof(rtp_send_packet));
while (1) {
rtp_send_packets( sock, &to);
sys_msleep(RTP_SEND_DELAY);
}
}
/* close the socket */
lwip_close(sock);
}
}
}
/**
* RTP recv thread
*/
static void
rtp_recv_thread(void *arg)
{
int sock;
struct sockaddr_in local;
struct sockaddr_in from;
int fromlen;
struct ip_mreq ipmreq;
struct rtp_hdr* rtphdr;
u32_t rtp_stream_address;
int timeout;
int result;
int recvrtppackets = 0;
int lostrtppackets = 0;
u16_t lastrtpseq = 0;
LWIP_UNUSED_ARG(arg);
/* initialize RTP stream address */
rtp_stream_address = RTP_STREAM_ADDRESS;
/* if we got a valid RTP stream address... */
if (rtp_stream_address != 0) {
/* create new socket */
sock = lwip_socket(AF_INET, SOCK_DGRAM, 0);
if (sock >= 0) {
/* prepare local address */
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_port = PP_HTONS(RTP_STREAM_PORT);
local.sin_addr.s_addr = PP_HTONL(INADDR_ANY);
/* bind to local address */
if (lwip_bind(sock, (struct sockaddr *)&local, sizeof(local)) == 0) {
/* set recv timeout */
timeout = RTP_RECV_TIMEOUT;
result = lwip_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
if (result) {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_recv_thread: setsockopt(SO_RCVTIMEO) failed: errno=%d\n", errno));
}
/* prepare multicast "ip_mreq" struct */
ipmreq.imr_multiaddr.s_addr = rtp_stream_address;
ipmreq.imr_interface.s_addr = PP_HTONL(INADDR_ANY);
/* join multicast group */
if (lwip_setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &ipmreq, sizeof(ipmreq)) == 0) {
/* receive RTP packets */
while(1) {
fromlen = sizeof(from);
result = lwip_recvfrom(sock, rtp_recv_packet, sizeof(rtp_recv_packet), 0,
(struct sockaddr *)&from, (socklen_t *)&fromlen);
if ((result > 0) && ((size_t)result >= sizeof(struct rtp_hdr))) {
size_t recved = (size_t)result;
rtphdr = (struct rtp_hdr *)rtp_recv_packet;
recvrtppackets++;
if ((lastrtpseq == 0) || ((lastrtpseq + 1) == lwip_ntohs(rtphdr->seqNum))) {
RTP_RECV_PROCESSING((rtp_recv_packet + sizeof(rtp_hdr)), (recved-sizeof(rtp_hdr)));
LWIP_UNUSED_ARG(recved); /* just in case... */
} else {
lostrtppackets++;
}
lastrtpseq = lwip_ntohs(rtphdr->seqNum);
if ((recvrtppackets % RTP_RECV_STATS) == 0) {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_recv_thread: recv %6i packet(s) / lost %4i packet(s) (%.4f%%)...\n", recvrtppackets, lostrtppackets, (lostrtppackets*100.0)/recvrtppackets));
}
} else {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_recv_thread: recv timeout...\n"));
}
}
/* leave multicast group */
/* TODO: this code is never reached
result = lwip_setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, &ipmreq, sizeof(ipmreq));
if (result) {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_recv_thread: setsockopt(IP_DROP_MEMBERSHIP) failed: errno=%d\n", errno));
}*/
}
}
/* close the socket */
lwip_close(sock);
}
}
}
void
rtp_init(void)
{
sys_thread_new("rtp_send_thread", rtp_send_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
sys_thread_new("rtp_recv_thread", rtp_recv_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
#endif /* LWIP_SOCKET && LWIP_IGMP */

View File

@@ -1,8 +0,0 @@
#ifndef LWIP_RTP_H
#define LWIP_RTP_H
#if LWIP_SOCKET && LWIP_IGMP
void rtp_init(void);
#endif /* LWIP_SOCKET && LWIP_IGMP */
#endif /* LWIP_RTP_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
/*
* 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 LWIP_SHELL_H
#define LWIP_SHELL_H
void shell_init(void);
#endif /* LWIP_SHELL_H */

View File

@@ -1,680 +0,0 @@
#include "socket_examples.h"
#include "lwip/opt.h"
#if LWIP_SOCKET && (LWIP_IPV4 || LWIP_IPV6)
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include <string.h>
#include <stdio.h>
#ifndef SOCK_TARGET_HOST4
#define SOCK_TARGET_HOST4 "192.168.0.1"
#endif
#ifndef SOCK_TARGET_HOST6
#define SOCK_TARGET_HOST6 "FE80::12:34FF:FE56:78AB"
#endif
#ifndef SOCK_TARGET_PORT
#define SOCK_TARGET_PORT 80
#endif
#ifndef SOCK_TARGET_MAXHTTPPAGESIZE
#define SOCK_TARGET_MAXHTTPPAGESIZE 1024
#endif
#ifndef SOCKET_EXAMPLES_RUN_PARALLEL
#define SOCKET_EXAMPLES_RUN_PARALLEL 0
#endif
static const u8_t cmpbuf[8] = {0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab};
/* a helper struct to ensure memory before/after fd_set is not touched */
typedef struct _xx
{
u8_t buf1[8];
fd_set readset;
u8_t buf2[8];
fd_set writeset;
u8_t buf3[8];
fd_set errset;
u8_t buf4[8];
} fdsets;
#define INIT_FDSETS(sets) do { \
memset((sets)->buf1, 0xab, 8); \
memset((sets)->buf2, 0xab, 8); \
memset((sets)->buf3, 0xab, 8); \
memset((sets)->buf4, 0xab, 8); \
}while(0)
#define CHECK_FDSETS(sets) do { \
LWIP_ASSERT("buf1 fail", !memcmp((sets)->buf1, cmpbuf, 8)); \
LWIP_ASSERT("buf2 fail", !memcmp((sets)->buf2, cmpbuf, 8)); \
LWIP_ASSERT("buf3 fail", !memcmp((sets)->buf3, cmpbuf, 8)); \
LWIP_ASSERT("buf4 fail", !memcmp((sets)->buf4, cmpbuf, 8)); \
}while(0)
static ip_addr_t dstaddr;
/** This is an example function that tests
blocking- and nonblocking connect. */
static void
sockex_nonblocking_connect(void *arg)
{
#if LWIP_SOCKET_SELECT
int s;
int ret;
int opt;
#if LWIP_IPV6
struct sockaddr_in6 addr;
#else /* LWIP_IPV6 */
struct sockaddr_in addr;
#endif /* LWIP_IPV6 */
fdsets sets;
struct timeval tv;
u32_t ticks_a, ticks_b;
int err;
const ip_addr_t *ipaddr = (const ip_addr_t*)arg;
struct pollfd fds;
INIT_FDSETS(&sets);
/* set up address to connect to */
memset(&addr, 0, sizeof(addr));
#if LWIP_IPV6
addr.sin6_len = sizeof(addr);
addr.sin6_family = AF_INET6;
addr.sin6_port = PP_HTONS(SOCK_TARGET_PORT);
inet6_addr_from_ip6addr(&addr.sin6_addr, ip_2_ip6(ipaddr));
#else /* LWIP_IPV6 */
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_port = PP_HTONS(SOCK_TARGET_PORT);
inet_addr_from_ip4addr(&addr.sin_addr, ip_2_ip4(ipaddr));
#endif /* LWIP_IPV6 */
/* first try blocking: */
/* create the socket */
#if LWIP_IPV6
s = lwip_socket(AF_INET6, SOCK_STREAM, 0);
#else /* LWIP_IPV6 */
s = lwip_socket(AF_INET, SOCK_STREAM, 0);
#endif /* LWIP_IPV6 */
LWIP_ASSERT("s >= 0", s >= 0);
/* connect */
ret = lwip_connect(s, (struct sockaddr*)&addr, sizeof(addr));
/* should succeed */
LWIP_ASSERT("ret == 0", ret == 0);
/* write something */
ret = lwip_write(s, "test", 4);
LWIP_ASSERT("ret == 4", ret == 4);
/* close */
ret = lwip_close(s);
LWIP_ASSERT("ret == 0", ret == 0);
/* now try nonblocking and close before being connected */
/* create the socket */
#if LWIP_IPV6
s = lwip_socket(AF_INET6, SOCK_STREAM, 0);
#else /* LWIP_IPV6 */
s = lwip_socket(AF_INET, SOCK_STREAM, 0);
#endif /* LWIP_IPV6 */
LWIP_ASSERT("s >= 0", s >= 0);
/* nonblocking */
opt = lwip_fcntl(s, F_GETFL, 0);
LWIP_ASSERT("ret != -1", ret != -1);
opt |= O_NONBLOCK;
ret = lwip_fcntl(s, F_SETFL, opt);
LWIP_ASSERT("ret != -1", ret != -1);
/* connect */
ret = lwip_connect(s, (struct sockaddr*)&addr, sizeof(addr));
/* should have an error: "inprogress" */
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EINPROGRESS", err == EINPROGRESS);
/* close */
ret = lwip_close(s);
LWIP_ASSERT("ret == 0", ret == 0);
/* try to close again, should fail with EBADF */
ret = lwip_close(s);
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EBADF", err == EBADF);
printf("closing socket in nonblocking connect succeeded\n");
/* now try nonblocking, connect should succeed:
this test only works if it is fast enough, i.e. no breakpoints, please! */
/* create the socket */
#if LWIP_IPV6
s = lwip_socket(AF_INET6, SOCK_STREAM, 0);
#else /* LWIP_IPV6 */
s = lwip_socket(AF_INET, SOCK_STREAM, 0);
#endif /* LWIP_IPV6 */
LWIP_ASSERT("s >= 0", s >= 0);
/* nonblocking */
opt = 1;
ret = lwip_ioctl(s, FIONBIO, &opt);
LWIP_ASSERT("ret == 0", ret == 0);
/* connect */
ret = lwip_connect(s, (struct sockaddr*)&addr, sizeof(addr));
/* should have an error: "inprogress" */
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EINPROGRESS", err == EINPROGRESS);
/* write should fail, too */
ret = lwip_write(s, "test", 4);
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EINPROGRESS", err == EINPROGRESS);
CHECK_FDSETS(&sets);
FD_ZERO(&sets.readset);
CHECK_FDSETS(&sets);
FD_SET(s, &sets.readset);
CHECK_FDSETS(&sets);
FD_ZERO(&sets.writeset);
CHECK_FDSETS(&sets);
FD_SET(s, &sets.writeset);
CHECK_FDSETS(&sets);
FD_ZERO(&sets.errset);
CHECK_FDSETS(&sets);
FD_SET(s, &sets.errset);
CHECK_FDSETS(&sets);
tv.tv_sec = 0;
tv.tv_usec = 0;
/* select without waiting should fail */
ret = lwip_select(s + 1, &sets.readset, &sets.writeset, &sets.errset, &tv);
CHECK_FDSETS(&sets);
LWIP_ASSERT("ret == 0", ret == 0);
LWIP_ASSERT("!FD_ISSET(s, &writeset)", !FD_ISSET(s, &sets.writeset));
LWIP_ASSERT("!FD_ISSET(s, &readset)", !FD_ISSET(s, &sets.readset));
LWIP_ASSERT("!FD_ISSET(s, &errset)", !FD_ISSET(s, &sets.errset));
fds.fd = s;
fds.events = POLLIN|POLLOUT;
fds.revents = 0;
ret = lwip_poll(&fds, 1, 0);
LWIP_ASSERT("ret == 0", ret == 0);
LWIP_ASSERT("fds.revents == 0", fds.revents == 0);
FD_ZERO(&sets.readset);
FD_SET(s, &sets.readset);
FD_ZERO(&sets.writeset);
FD_SET(s, &sets.writeset);
FD_ZERO(&sets.errset);
FD_SET(s, &sets.errset);
ticks_a = sys_now();
/* select with waiting should succeed */
ret = lwip_select(s + 1, &sets.readset, &sets.writeset, &sets.errset, NULL);
ticks_b = sys_now();
LWIP_ASSERT("ret == 1", ret == 1);
LWIP_ASSERT("FD_ISSET(s, &writeset)", FD_ISSET(s, &sets.writeset));
LWIP_ASSERT("!FD_ISSET(s, &readset)", !FD_ISSET(s, &sets.readset));
LWIP_ASSERT("!FD_ISSET(s, &errset)", !FD_ISSET(s, &sets.errset));
fds.fd = s;
fds.events = POLLIN|POLLOUT;
fds.revents = 0;
ret = lwip_poll(&fds, 1, 0);
LWIP_ASSERT("ret == 1", ret == 1);
LWIP_ASSERT("fds.revents & POLLOUT", fds.revents & POLLOUT);
/* now write should succeed */
ret = lwip_write(s, "test", 4);
LWIP_ASSERT("ret == 4", ret == 4);
/* close */
ret = lwip_close(s);
LWIP_ASSERT("ret == 0", ret == 0);
printf("select() needed %d ticks to return writable\n", (int)(ticks_b - ticks_a));
/* now try nonblocking to invalid address:
this test only works if it is fast enough, i.e. no breakpoints, please! */
/* create the socket */
#if LWIP_IPV6
s = lwip_socket(AF_INET6, SOCK_STREAM, 0);
#else /* LWIP_IPV6 */
s = lwip_socket(AF_INET, SOCK_STREAM, 0);
#endif /* LWIP_IPV6 */
LWIP_ASSERT("s >= 0", s >= 0);
/* nonblocking */
opt = 1;
ret = lwip_ioctl(s, FIONBIO, &opt);
LWIP_ASSERT("ret == 0", ret == 0);
#if LWIP_IPV6
addr.sin6_addr.un.u8_addr[0]++; /* this should result in an invalid address */
#else /* LWIP_IPV6 */
addr.sin_addr.s_addr++; /* this should result in an invalid address */
#endif /* LWIP_IPV6 */
/* connect */
ret = lwip_connect(s, (struct sockaddr*)&addr, sizeof(addr));
/* should have an error: "inprogress" */
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EINPROGRESS", err == EINPROGRESS);
/* write should fail, too */
ret = lwip_write(s, "test", 4);
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EINPROGRESS", err == EINPROGRESS);
LWIP_UNUSED_ARG(err);
FD_ZERO(&sets.readset);
FD_SET(s, &sets.readset);
FD_ZERO(&sets.writeset);
FD_SET(s, &sets.writeset);
FD_ZERO(&sets.errset);
FD_SET(s, &sets.errset);
tv.tv_sec = 0;
tv.tv_usec = 0;
/* select without waiting should fail */
ret = lwip_select(s + 1, &sets.readset, &sets.writeset, &sets.errset, &tv);
LWIP_ASSERT("ret == 0", ret == 0);
FD_ZERO(&sets.readset);
FD_SET(s, &sets.readset);
FD_ZERO(&sets.writeset);
FD_SET(s, &sets.writeset);
FD_ZERO(&sets.errset);
FD_SET(s, &sets.errset);
ticks_a = sys_now();
/* select with waiting should eventually succeed and return errset! */
ret = lwip_select(s + 1, &sets.readset, &sets.writeset, &sets.errset, NULL);
ticks_b = sys_now();
LWIP_ASSERT("ret > 0", ret > 0);
LWIP_ASSERT("FD_ISSET(s, &errset)", FD_ISSET(s, &sets.errset));
/*LWIP_ASSERT("!FD_ISSET(s, &readset)", !FD_ISSET(s, &sets.readset));
LWIP_ASSERT("!FD_ISSET(s, &writeset)", !FD_ISSET(s, &sets.writeset));*/
/* close */
ret = lwip_close(s);
LWIP_ASSERT("ret == 0", ret == 0);
LWIP_UNUSED_ARG(ret);
printf("select() needed %d ticks to return error\n", (int)(ticks_b - ticks_a));
printf("sockex_nonblocking_connect finished successfully\n");
#else
LWIP_UNUSED_ARG(arg);
#endif
}
/** This is an example function that tests
the recv function (timeout etc.). */
static void
sockex_testrecv(void *arg)
{
int s;
int ret;
int err;
#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
int opt, opt2;
#else
struct timeval opt, opt2;
#endif
socklen_t opt2size;
#if LWIP_IPV6
struct sockaddr_in6 addr;
#else /* LWIP_IPV6 */
struct sockaddr_in addr;
#endif /* LWIP_IPV6 */
size_t len;
char rxbuf[SOCK_TARGET_MAXHTTPPAGESIZE];
#if LWIP_SOCKET_SELECT
fd_set readset;
fd_set errset;
struct timeval tv;
#endif
const ip_addr_t *ipaddr = (const ip_addr_t*)arg;
/* set up address to connect to */
memset(&addr, 0, sizeof(addr));
#if LWIP_IPV6
addr.sin6_len = sizeof(addr);
addr.sin6_family = AF_INET6;
addr.sin6_port = PP_HTONS(SOCK_TARGET_PORT);
inet6_addr_from_ip6addr(&addr.sin6_addr, ip_2_ip6(ipaddr));
#else /* LWIP_IPV6 */
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_port = PP_HTONS(SOCK_TARGET_PORT);
inet_addr_from_ip4addr(&addr.sin_addr, ip_2_ip4(ipaddr));
#endif /* LWIP_IPV6 */
/* first try blocking: */
/* create the socket */
#if LWIP_IPV6
s = lwip_socket(AF_INET6, SOCK_STREAM, 0);
#else /* LWIP_IPV6 */
s = lwip_socket(AF_INET, SOCK_STREAM, 0);
#endif /* LWIP_IPV6 */
LWIP_ASSERT("s >= 0", s >= 0);
/* connect */
ret = lwip_connect(s, (struct sockaddr*)&addr, sizeof(addr));
/* should succeed */
LWIP_ASSERT("ret == 0", ret == 0);
/* set recv timeout (100 ms) */
#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
opt = 100;
#else
opt.tv_sec = 0;
opt.tv_usec = 100 * 1000;
#endif
ret = lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &opt, sizeof(opt));
LWIP_ASSERT("ret == 0", ret == 0);
#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
opt2 = 0;
#else
opt2.tv_sec = 0;
opt2.tv_usec = 0;
#endif
opt2size = sizeof(opt2);
ret = lwip_getsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &opt2, &opt2size);
LWIP_ASSERT("ret == 0", ret == 0);
LWIP_ASSERT("opt2size == sizeof(opt2)", opt2size == sizeof(opt2));
#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
LWIP_ASSERT("opt == opt2", opt == opt2);
#else
LWIP_ASSERT("opt == opt2", opt.tv_sec == opt2.tv_sec);
LWIP_ASSERT("opt == opt2", opt.tv_usec == opt2.tv_usec);
#endif
/* write the start of a GET request */
#define SNDSTR1 "G"
len = strlen(SNDSTR1);
ret = lwip_write(s, SNDSTR1, len);
LWIP_ASSERT("ret == len", ret == (int)len);
/* should time out if the other side is a good HTTP server */
ret = lwip_read(s, rxbuf, 1);
LWIP_ASSERT("ret == -1", ret == -1);
err = errno;
LWIP_ASSERT("errno == EAGAIN", err == EAGAIN);
LWIP_UNUSED_ARG(err);
/* write the rest of a GET request */
#define SNDSTR2 "ET / HTTP_1.1\r\n\r\n"
len = strlen(SNDSTR2);
ret = lwip_write(s, SNDSTR2, len);
LWIP_ASSERT("ret == len", ret == (int)len);
/* wait a while: should be enough for the server to send a response */
sys_msleep(1000);
/* should not time out but receive a response */
ret = lwip_read(s, rxbuf, SOCK_TARGET_MAXHTTPPAGESIZE);
LWIP_ASSERT("ret > 0", ret > 0);
#if LWIP_SOCKET_SELECT
/* now select should directly return because the socket is readable */
FD_ZERO(&readset);
FD_ZERO(&errset);
FD_SET(s, &readset);
FD_SET(s, &errset);
tv.tv_sec = 10;
tv.tv_usec = 0;
ret = lwip_select(s + 1, &readset, NULL, &errset, &tv);
LWIP_ASSERT("ret == 1", ret == 1);
LWIP_ASSERT("!FD_ISSET(s, &errset)", !FD_ISSET(s, &errset));
LWIP_ASSERT("FD_ISSET(s, &readset)", FD_ISSET(s, &readset));
#endif
/* should not time out but receive a response */
ret = lwip_read(s, rxbuf, SOCK_TARGET_MAXHTTPPAGESIZE);
/* might receive a second packet for HTTP/1.1 servers */
if (ret > 0) {
/* should return 0: closed */
ret = lwip_read(s, rxbuf, SOCK_TARGET_MAXHTTPPAGESIZE);
LWIP_ASSERT("ret == 0", ret == 0);
}
/* close */
ret = lwip_close(s);
LWIP_ASSERT("ret == 0", ret == 0);
LWIP_UNUSED_ARG(ret);
printf("sockex_testrecv finished successfully\n");
}
#if LWIP_SOCKET_SELECT
/** helper struct for the 2 functions below (multithreaded: thread-argument) */
struct sockex_select_helper {
int socket;
int wait_read;
int expect_read;
int wait_write;
int expect_write;
int wait_err;
int expect_err;
int wait_ms;
sys_sem_t sem;
};
/** helper thread to wait for socket events using select */
static void
sockex_select_waiter(void *arg)
{
struct sockex_select_helper *helper = (struct sockex_select_helper *)arg;
int ret;
fd_set readset;
fd_set writeset;
fd_set errset;
struct timeval tv;
LWIP_ASSERT("helper != NULL", helper != NULL);
FD_ZERO(&readset);
FD_ZERO(&writeset);
FD_ZERO(&errset);
if (helper->wait_read) {
FD_SET(helper->socket, &readset);
}
if (helper->wait_write) {
FD_SET(helper->socket, &writeset);
}
if (helper->wait_err) {
FD_SET(helper->socket, &errset);
}
tv.tv_sec = helper->wait_ms / 1000;
tv.tv_usec = (helper->wait_ms % 1000) * 1000;
ret = lwip_select(helper->socket, &readset, &writeset, &errset, &tv);
if (helper->expect_read || helper->expect_write || helper->expect_err) {
LWIP_ASSERT("ret > 0", ret > 0);
} else {
LWIP_ASSERT("ret == 0", ret == 0);
}
LWIP_UNUSED_ARG(ret);
if (helper->expect_read) {
LWIP_ASSERT("FD_ISSET(helper->socket, &readset)", FD_ISSET(helper->socket, &readset));
} else {
LWIP_ASSERT("!FD_ISSET(helper->socket, &readset)", !FD_ISSET(helper->socket, &readset));
}
if (helper->expect_write) {
LWIP_ASSERT("FD_ISSET(helper->socket, &writeset)", FD_ISSET(helper->socket, &writeset));
} else {
LWIP_ASSERT("!FD_ISSET(helper->socket, &writeset)", !FD_ISSET(helper->socket, &writeset));
}
if (helper->expect_err) {
LWIP_ASSERT("FD_ISSET(helper->socket, &errset)", FD_ISSET(helper->socket, &errset));
} else {
LWIP_ASSERT("!FD_ISSET(helper->socket, &errset)", !FD_ISSET(helper->socket, &errset));
}
sys_sem_signal(&helper->sem);
}
/** This is an example function that tests
more than one thread being active in select. */
static void
sockex_testtwoselects(void *arg)
{
int s1;
int s2;
int ret;
#if LWIP_IPV6
struct sockaddr_in6 addr;
#else /* LWIP_IPV6 */
struct sockaddr_in addr;
#endif /* LWIP_IPV6 */
size_t len;
err_t lwiperr;
struct sockex_select_helper h1, h2, h3, h4;
const ip_addr_t *ipaddr = (const ip_addr_t*)arg;
/* set up address to connect to */
memset(&addr, 0, sizeof(addr));
#if LWIP_IPV6
addr.sin6_len = sizeof(addr);
addr.sin6_family = AF_INET6;
addr.sin6_port = PP_HTONS(SOCK_TARGET_PORT);
inet6_addr_from_ip6addr(&addr.sin6_addr, ip_2_ip6(ipaddr));
#else /* LWIP_IPV6 */
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_port = PP_HTONS(SOCK_TARGET_PORT);
inet_addr_from_ip4addr(&addr.sin_addr, ip_2_ip4(ipaddr));
#endif /* LWIP_IPV6 */
/* create the sockets */
#if LWIP_IPV6
s1 = lwip_socket(AF_INET6, SOCK_STREAM, 0);
s2 = lwip_socket(AF_INET6, SOCK_STREAM, 0);
#else /* LWIP_IPV6 */
s1 = lwip_socket(AF_INET, SOCK_STREAM, 0);
s2 = lwip_socket(AF_INET, SOCK_STREAM, 0);
#endif /* LWIP_IPV6 */
LWIP_ASSERT("s1 >= 0", s1 >= 0);
LWIP_ASSERT("s2 >= 0", s2 >= 0);
/* connect, should succeed */
ret = lwip_connect(s1, (struct sockaddr*)&addr, sizeof(addr));
LWIP_ASSERT("ret == 0", ret == 0);
ret = lwip_connect(s2, (struct sockaddr*)&addr, sizeof(addr));
LWIP_ASSERT("ret == 0", ret == 0);
/* write the start of a GET request */
#define SNDSTR1 "G"
len = strlen(SNDSTR1);
ret = lwip_write(s1, SNDSTR1, len);
LWIP_ASSERT("ret == len", ret == (int)len);
ret = lwip_write(s2, SNDSTR1, len);
LWIP_ASSERT("ret == len", ret == (int)len);
LWIP_UNUSED_ARG(ret);
h1.wait_read = 1;
h1.wait_write = 1;
h1.wait_err = 1;
h1.expect_read = 0;
h1.expect_write = 0;
h1.expect_err = 0;
lwiperr = sys_sem_new(&h1.sem, 0);
LWIP_ASSERT("lwiperr == ERR_OK", lwiperr == ERR_OK);
h1.socket = s1;
h1.wait_ms = 500;
h2 = h1;
lwiperr = sys_sem_new(&h2.sem, 0);
LWIP_ASSERT("lwiperr == ERR_OK", lwiperr == ERR_OK);
h2.socket = s2;
h2.wait_ms = 1000;
h3 = h1;
lwiperr = sys_sem_new(&h3.sem, 0);
LWIP_ASSERT("lwiperr == ERR_OK", lwiperr == ERR_OK);
h3.socket = s2;
h3.wait_ms = 1500;
h4 = h1;
lwiperr = sys_sem_new(&h4.sem, 0);
LWIP_ASSERT("lwiperr == ERR_OK", lwiperr == ERR_OK);
LWIP_UNUSED_ARG(lwiperr);
h4.socket = s2;
h4.wait_ms = 2000;
/* select: all sockets should time out if the other side is a good HTTP server */
sys_thread_new("sockex_select_waiter1", sockex_select_waiter, &h2, 0, 0);
sys_msleep(100);
sys_thread_new("sockex_select_waiter2", sockex_select_waiter, &h1, 0, 0);
sys_msleep(100);
sys_thread_new("sockex_select_waiter2", sockex_select_waiter, &h4, 0, 0);
sys_msleep(100);
sys_thread_new("sockex_select_waiter2", sockex_select_waiter, &h3, 0, 0);
sys_sem_wait(&h1.sem);
sys_sem_wait(&h2.sem);
sys_sem_wait(&h3.sem);
sys_sem_wait(&h4.sem);
/* close */
ret = lwip_close(s1);
LWIP_ASSERT("ret == 0", ret == 0);
ret = lwip_close(s2);
LWIP_ASSERT("ret == 0", ret == 0);
printf("sockex_testtwoselects finished successfully\n");
}
#else
static void
sockex_testtwoselects(void *arg)
{
LWIP_UNUSED_ARG(arg);
}
#endif
#if !SOCKET_EXAMPLES_RUN_PARALLEL
static void
socket_example_test(void* arg)
{
sys_msleep(1000);
sockex_nonblocking_connect(arg);
sockex_testrecv(arg);
sockex_testtwoselects(arg);
printf("all tests done, thread ending\n");
}
#endif
void socket_examples_init(void)
{
int addr_ok;
#if LWIP_IPV6
IP_SET_TYPE_VAL(dstaddr, IPADDR_TYPE_V6);
addr_ok = ip6addr_aton(SOCK_TARGET_HOST6, ip_2_ip6(&dstaddr));
#else /* LWIP_IPV6 */
IP_SET_TYPE_VAL(dstaddr, IPADDR_TYPE_V4);
addr_ok = ip4addr_aton(SOCK_TARGET_HOST4, ip_2_ip4(&dstaddr));
#endif /* LWIP_IPV6 */
LWIP_ASSERT("invalid address", addr_ok);
#if SOCKET_EXAMPLES_RUN_PARALLEL
sys_thread_new("sockex_nonblocking_connect", sockex_nonblocking_connect, &dstaddr, 0, 0);
sys_thread_new("sockex_testrecv", sockex_testrecv, &dstaddr, 0, 0);
sys_thread_new("sockex_testtwoselects", sockex_testtwoselects, &dstaddr, 0, 0);
#else
sys_thread_new("socket_example_test", socket_example_test, &dstaddr, 0, 0);
#endif
}
#endif /* LWIP_SOCKET */

View File

@@ -1,6 +0,0 @@
#ifndef LWIP_SOCKET_EXAMPLES_H
#define LWIP_SOCKET_EXAMPLES_H
void socket_examples_init(void);
#endif /* LWIP_SOCKET_EXAMPLES_H */

View File

@@ -1,101 +0,0 @@
/*
* 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>
*
*/
#include "tcpecho.h"
#include "lwip/opt.h"
#if LWIP_NETCONN
#include "lwip/sys.h"
#include "lwip/api.h"
/*-----------------------------------------------------------------------------------*/
static void
tcpecho_thread(void *arg)
{
struct netconn *conn, *newconn;
err_t err;
LWIP_UNUSED_ARG(arg);
/* Create a new connection identifier. */
/* Bind connection to well known port number 7. */
#if LWIP_IPV6
conn = netconn_new(NETCONN_TCP_IPV6);
netconn_bind(conn, IP6_ADDR_ANY, 7);
#else /* LWIP_IPV6 */
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, IP_ADDR_ANY, 7);
#endif /* LWIP_IPV6 */
LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);
/* Tell connection to go into listening mode. */
netconn_listen(conn);
while (1) {
/* Grab new connection. */
err = netconn_accept(conn, &newconn);
/*printf("accepted new connection %p\n", newconn);*/
/* Process the new connection. */
if (err == ERR_OK) {
struct netbuf *buf;
void *data;
u16_t len;
while ((err = netconn_recv(newconn, &buf)) == ERR_OK) {
/*printf("Recved\n");*/
do {
netbuf_data(buf, &data, &len);
err = netconn_write(newconn, data, len, NETCONN_COPY);
#if 0
if (err != ERR_OK) {
printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));
}
#endif
} while (netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
/*printf("Got EOF, looping\n");*/
/* Close connection and discard connection identifier. */
netconn_close(newconn);
netconn_delete(newconn);
}
}
}
/*-----------------------------------------------------------------------------------*/
void
tcpecho_init(void)
{
sys_thread_new("tcpecho_thread", tcpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
/*-----------------------------------------------------------------------------------*/
#endif /* LWIP_NETCONN */

View File

@@ -1,38 +0,0 @@
/*
* 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 LWIP_TCPECHO_H
#define LWIP_TCPECHO_H
void tcpecho_init(void);
#endif /* LWIP_TCPECHO_H */

View File

@@ -1,301 +0,0 @@
/*
* 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 and a contribution to the lwIP TCP/IP stack.
*
* Credits go to Adam Dunkels (and the current maintainers) of this software.
*
* Christiaan Simons rewrote this file to get a more stable echo example.
*/
/**
* @file
* TCP echo server example using raw API.
*
* Echos all bytes sent by connecting client,
* and passively closes when client is done.
*
*/
#include "lwip/opt.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/tcp.h"
#include "tcpecho_raw.h"
#if LWIP_TCP && LWIP_CALLBACK_API
static struct tcp_pcb *tcpecho_raw_pcb;
enum tcpecho_raw_states
{
ES_NONE = 0,
ES_ACCEPTED,
ES_RECEIVED,
ES_CLOSING
};
struct tcpecho_raw_state
{
u8_t state;
u8_t retries;
struct tcp_pcb *pcb;
/* pbuf (chain) to recycle */
struct pbuf *p;
};
static void
tcpecho_raw_free(struct tcpecho_raw_state *es)
{
if (es != NULL) {
if (es->p) {
/* free the buffer chain if present */
pbuf_free(es->p);
}
mem_free(es);
}
}
static void
tcpecho_raw_close(struct tcp_pcb *tpcb, struct tcpecho_raw_state *es)
{
tcp_arg(tpcb, NULL);
tcp_sent(tpcb, NULL);
tcp_recv(tpcb, NULL);
tcp_err(tpcb, NULL);
tcp_poll(tpcb, NULL, 0);
tcpecho_raw_free(es);
tcp_close(tpcb);
}
static void
tcpecho_raw_send(struct tcp_pcb *tpcb, struct tcpecho_raw_state *es)
{
struct pbuf *ptr;
err_t wr_err = ERR_OK;
while ((wr_err == ERR_OK) &&
(es->p != NULL) &&
(es->p->len <= tcp_sndbuf(tpcb))) {
ptr = es->p;
/* enqueue data for transmission */
wr_err = tcp_write(tpcb, ptr->payload, ptr->len, 1);
if (wr_err == ERR_OK) {
u16_t plen;
plen = ptr->len;
/* continue with next pbuf in chain (if any) */
es->p = ptr->next;
if(es->p != NULL) {
/* new reference! */
pbuf_ref(es->p);
}
/* chop first pbuf from chain */
pbuf_free(ptr);
/* we can read more data now */
tcp_recved(tpcb, plen);
} else if(wr_err == ERR_MEM) {
/* we are low on memory, try later / harder, defer to poll */
es->p = ptr;
} else {
/* other problem ?? */
}
}
}
static void
tcpecho_raw_error(void *arg, err_t err)
{
struct tcpecho_raw_state *es;
LWIP_UNUSED_ARG(err);
es = (struct tcpecho_raw_state *)arg;
tcpecho_raw_free(es);
}
static err_t
tcpecho_raw_poll(void *arg, struct tcp_pcb *tpcb)
{
err_t ret_err;
struct tcpecho_raw_state *es;
es = (struct tcpecho_raw_state *)arg;
if (es != NULL) {
if (es->p != NULL) {
/* there is a remaining pbuf (chain) */
tcpecho_raw_send(tpcb, es);
} else {
/* no remaining pbuf (chain) */
if(es->state == ES_CLOSING) {
tcpecho_raw_close(tpcb, es);
}
}
ret_err = ERR_OK;
} else {
/* nothing to be done */
tcp_abort(tpcb);
ret_err = ERR_ABRT;
}
return ret_err;
}
static err_t
tcpecho_raw_sent(void *arg, struct tcp_pcb *tpcb, u16_t len)
{
struct tcpecho_raw_state *es;
LWIP_UNUSED_ARG(len);
es = (struct tcpecho_raw_state *)arg;
es->retries = 0;
if(es->p != NULL) {
/* still got pbufs to send */
tcp_sent(tpcb, tcpecho_raw_sent);
tcpecho_raw_send(tpcb, es);
} else {
/* no more pbufs to send */
if(es->state == ES_CLOSING) {
tcpecho_raw_close(tpcb, es);
}
}
return ERR_OK;
}
static err_t
tcpecho_raw_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
struct tcpecho_raw_state *es;
err_t ret_err;
LWIP_ASSERT("arg != NULL",arg != NULL);
es = (struct tcpecho_raw_state *)arg;
if (p == NULL) {
/* remote host closed connection */
es->state = ES_CLOSING;
if(es->p == NULL) {
/* we're done sending, close it */
tcpecho_raw_close(tpcb, es);
} else {
/* we're not done yet */
tcpecho_raw_send(tpcb, es);
}
ret_err = ERR_OK;
} else if(err != ERR_OK) {
/* cleanup, for unknown reason */
LWIP_ASSERT("no pbuf expected here", p == NULL);
ret_err = err;
}
else if(es->state == ES_ACCEPTED) {
/* first data chunk in p->payload */
es->state = ES_RECEIVED;
/* store reference to incoming pbuf (chain) */
es->p = p;
tcpecho_raw_send(tpcb, es);
ret_err = ERR_OK;
} else if (es->state == ES_RECEIVED) {
/* read some more data */
if(es->p == NULL) {
es->p = p;
tcpecho_raw_send(tpcb, es);
} else {
struct pbuf *ptr;
/* chain pbufs to the end of what we recv'ed previously */
ptr = es->p;
pbuf_cat(ptr,p);
}
ret_err = ERR_OK;
} else {
/* unknown es->state, trash data */
tcp_recved(tpcb, p->tot_len);
pbuf_free(p);
ret_err = ERR_OK;
}
return ret_err;
}
static err_t
tcpecho_raw_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
{
err_t ret_err;
struct tcpecho_raw_state *es;
LWIP_UNUSED_ARG(arg);
if ((err != ERR_OK) || (newpcb == NULL)) {
return ERR_VAL;
}
/* Unless this pcb should have NORMAL priority, set its priority now.
When running out of pcbs, low priority pcbs can be aborted to create
new pcbs of higher priority. */
tcp_setprio(newpcb, TCP_PRIO_MIN);
es = (struct tcpecho_raw_state *)mem_malloc(sizeof(struct tcpecho_raw_state));
if (es != NULL) {
es->state = ES_ACCEPTED;
es->pcb = newpcb;
es->retries = 0;
es->p = NULL;
/* pass newly allocated es to our callbacks */
tcp_arg(newpcb, es);
tcp_recv(newpcb, tcpecho_raw_recv);
tcp_err(newpcb, tcpecho_raw_error);
tcp_poll(newpcb, tcpecho_raw_poll, 0);
tcp_sent(newpcb, tcpecho_raw_sent);
ret_err = ERR_OK;
} else {
ret_err = ERR_MEM;
}
return ret_err;
}
void
tcpecho_raw_init(void)
{
tcpecho_raw_pcb = tcp_new_ip_type(IPADDR_TYPE_ANY);
if (tcpecho_raw_pcb != NULL) {
err_t err;
err = tcp_bind(tcpecho_raw_pcb, IP_ANY_TYPE, 7);
if (err == ERR_OK) {
tcpecho_raw_pcb = tcp_listen(tcpecho_raw_pcb);
tcp_accept(tcpecho_raw_pcb, tcpecho_raw_accept);
} else {
/* abort? output diagnostic? */
}
} else {
/* abort? output diagnostic? */
}
}
#endif /* LWIP_TCP && LWIP_CALLBACK_API */

View File

@@ -1,35 +0,0 @@
/*
* 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.
*
*/
#ifndef LWIP_TCPECHO_RAW_H
#define LWIP_TCPECHO_RAW_H
void tcpecho_raw_init(void);
#endif /* LWIP_TCPECHO_RAW_H */

View File

@@ -1,88 +0,0 @@
/*
* 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>
*
*/
#include "udpecho.h"
#include "lwip/opt.h"
#if LWIP_NETCONN
#include "lwip/api.h"
#include "lwip/sys.h"
/*-----------------------------------------------------------------------------------*/
static void
udpecho_thread(void *arg)
{
struct netconn *conn;
struct netbuf *buf;
char buffer[4096];
err_t err;
LWIP_UNUSED_ARG(arg);
#if LWIP_IPV6
conn = netconn_new(NETCONN_UDP_IPV6);
LWIP_ERROR("udpecho: invalid conn", (conn != NULL), return;);
netconn_bind(conn, IP6_ADDR_ANY, 7);
#else /* LWIP_IPV6 */
conn = netconn_new(NETCONN_UDP);
LWIP_ERROR("udpecho: invalid conn", (conn != NULL), return;);
netconn_bind(conn, IP_ADDR_ANY, 7);
#endif /* LWIP_IPV6 */
while (1) {
err = netconn_recv(conn, &buf);
if (err == ERR_OK) {
/* no need netconn_connect here, since the netbuf contains the address */
if(netbuf_copy(buf, buffer, sizeof(buffer)) != buf->p->tot_len) {
LWIP_DEBUGF(LWIP_DBG_ON, ("netbuf_copy failed\n"));
} else {
buffer[buf->p->tot_len] = '\0';
err = netconn_send(conn, buf);
if(err != ERR_OK) {
LWIP_DEBUGF(LWIP_DBG_ON, ("netconn_send failed: %d\n", (int)err));
} else {
LWIP_DEBUGF(LWIP_DBG_ON, ("got %s\n", buffer));
}
}
netbuf_delete(buf);
}
}
}
/*-----------------------------------------------------------------------------------*/
void
udpecho_init(void)
{
sys_thread_new("udpecho_thread", udpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
#endif /* LWIP_NETCONN */

View File

@@ -1,37 +0,0 @@
/*
* 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 LWIP_UDPECHO_H
#define LWIP_UDPECHO_H
void udpecho_init(void);
#endif /* LWIP_UDPECHO_H */

View File

@@ -1,88 +0,0 @@
/*
* Copyright (c) 2016 Stephan Linz <linz@li-pro.net>, Li-Pro.Net
* All rights reserved.
*
* Based on examples provided by
* Iwan Budi Kusnanto <ibk@labhijau.net> (https://gist.github.com/iwanbk/1399729)
* Juri Haberland <juri@sapienti-sat.org> (https://lists.gnu.org/archive/html/lwip-users/2007-06/msg00078.html)
*
* 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 and a contribution to the lwIP TCP/IP stack.
*
* Credits go to Adam Dunkels (and the current maintainers) of this software.
*
* Stephan Linz rewrote this file to get a basic echo example.
*/
/**
* @file
* UDP echo server example using raw API.
*
* Echos all bytes sent by connecting client,
* and passively closes when client is done.
*
*/
#include "lwip/opt.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/udp.h"
#include "udpecho_raw.h"
#if LWIP_UDP
static struct udp_pcb *udpecho_raw_pcb;
static void
udpecho_raw_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
const ip_addr_t *addr, u16_t port)
{
LWIP_UNUSED_ARG(arg);
if (p != NULL) {
/* send received packet back to sender */
udp_sendto(upcb, p, addr, port);
/* free the pbuf */
pbuf_free(p);
}
}
void
udpecho_raw_init(void)
{
udpecho_raw_pcb = udp_new_ip_type(IPADDR_TYPE_ANY);
if (udpecho_raw_pcb != NULL) {
err_t err;
err = udp_bind(udpecho_raw_pcb, IP_ANY_TYPE, 7);
if (err == ERR_OK) {
udp_recv(udpecho_raw_pcb, udpecho_raw_recv, NULL);
} else {
/* abort? output diagnostic? */
}
} else {
/* abort? output diagnostic? */
}
}
#endif /* LWIP_UDP */

View File

@@ -1,39 +0,0 @@
/*
* Copyright (c) 2016 Stephan Linz <linz@li-pro.net>, Li-Pro.Net
* All rights reserved.
*
* Based on examples provided by
* Iwan Budi Kusnanto <ibk@labhijau.net> (https://gist.github.com/iwanbk/1399729)
* Juri Haberland <juri@sapienti-sat.org> (https://lists.gnu.org/archive/html/lwip-users/2007-06/msg00078.html)
*
* 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.
*
*/
#ifndef LWIP_UDPECHO_RAW_H
#define LWIP_UDPECHO_RAW_H
void udpecho_raw_init(void);
#endif /* LWIP_UDPECHO_RAW_H */

View File

@@ -1,47 +0,0 @@
/*
* 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 LWIP_DEFAULT_NETIF_H
#define LWIP_DEFAULT_NETIF_H
#include "lwip/ip_addr.h"
#if LWIP_IPV4
void init_default_netif(const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw);
#else
void init_default_netif(void);
#endif
void default_netif_poll(void);
void default_netif_shutdown(void);
#endif

View File

@@ -1,73 +0,0 @@
/**
* Additional settings for the example app.
* Copy this to lwipcfg.h and make the config changes you need.
*/
/* configuration for this port */
#define PPP_USERNAME "Admin"
#define PPP_PASSWORD "pass"
/** Define this to the index of the windows network adapter to use */
#define PACKET_LIB_ADAPTER_NR 1
/** Define this to the GUID of the windows network adapter to use
* or NOT define this if you want PACKET_LIB_ADAPTER_NR to be used */
/*#define PACKET_LIB_ADAPTER_GUID "00000000-0000-0000-0000-000000000000"*/
/*#define PACKET_LIB_GET_ADAPTER_NETADDRESS(addr) IP4_ADDR((addr), 192,168,1,0)*/
/*#define PACKET_LIB_QUIET*/
/* #define USE_PCAPIF 1 */
#define LWIP_PORT_INIT_IPADDR(addr) IP4_ADDR((addr), 192,168,1,200)
#define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), 192,168,1,1)
#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255,255,255,0)
/* remember to change this MAC address to suit your needs!
the last octet will be increased by netif->num for each netif */
#define LWIP_MAC_ADDR_BASE {0x00,0x01,0x02,0x03,0x04,0x05}
/* #define USE_SLIPIF 0 */
/* #define SIO_USE_COMPORT 0 */
#ifdef USE_SLIPIF
#if USE_SLIPIF
#define LWIP_PORT_INIT_SLIP1_IPADDR(addr) IP4_ADDR((addr), 192, 168, 2, 2)
#define LWIP_PORT_INIT_SLIP1_GW(addr) IP4_ADDR((addr), 192, 168, 2, 1)
#define LWIP_PORT_INIT_SLIP1_NETMASK(addr) IP4_ADDR((addr), 255, 255, 255, 0)
#if USE_SLIPIF > 1
#define LWIP_PORT_INIT_SLIP2_IPADDR(addr) IP4_ADDR((addr), 192, 168, 2, 1)
#define LWIP_PORT_INIT_SLIP2_GW(addr) IP4_ADDR((addr), 0, 0, 0, 0)
#define LWIP_PORT_INIT_SLIP2_NETMASK(addr) IP4_ADDR((addr), 255, 255, 255, 0)*/
#endif /* USE_SLIPIF > 1 */
#endif /* USE_SLIPIF */
#endif /* USE_SLIPIF */
/* configuration for applications */
#define LWIP_CHARGEN_APP 1
#define LWIP_DNS_APP 1
#define LWIP_HTTPD_APP LWIP_TCP
/* Set this to 1 to use the netconn http server,
* otherwise the raw api server will be used. */
/*#define LWIP_HTTPD_APP_NETCONN */
#define LWIP_NETBIOS_APP LWIP_IPV4 && LWIP_UDP
#define LWIP_NETIO_APP 1
#define LWIP_MDNS_APP LWIP_UDP
#define LWIP_MQTT_APP LWIP_TCP
#define LWIP_PING_APP 1
#define LWIP_RTP_APP 1
#define LWIP_SHELL_APP LWIP_TCP
#define LWIP_SNMP_APP LWIP_UDP
#define LWIP_SNTP_APP LWIP_UDP
#define LWIP_SOCKET_EXAMPLES_APP 1
#define LWIP_TCPECHO_APP LWIP_TCP
/* Set this to 1 to use the netconn tcpecho server,
* otherwise the raw api server will be used. */
/*#define LWIP_TCPECHO_APP_NETCONN */
#define LWIP_TFTP_APP LWIP_UDP
#define LWIP_TFTP_CLIENT_APP LWIP_UDP
#define LWIP_UDPECHO_APP LWIP_UDP
#define LWIP_LWIPERF_APP LWIP_TCP
#define USE_DHCP LWIP_DHCP
#define USE_AUTOIP LWIP_AUTOIP
/* define this to your custom application-init function */
/* #define LWIP_APP_INIT my_app_init() */

View File

@@ -1,77 +0,0 @@
/**
* Additional settings for the example app.
* Copy this to lwipcfg.h and make the config changes you need.
*/
/* configuration for this port */
#define PPP_USERNAME "Admin"
#define PPP_PASSWORD "pass"
/** Define this to the index of the windows network adapter to use */
#define PACKET_LIB_ADAPTER_NR 1
/** Define this to the GUID of the windows network adapter to use
* or NOT define this if you want PACKET_LIB_ADAPTER_NR to be used */
/*#define PACKET_LIB_ADAPTER_GUID "00000000-0000-0000-0000-000000000000"*/
/*#define PACKET_LIB_GET_ADAPTER_NETADDRESS(addr) IP4_ADDR((addr), 192,168,1,0)*/
/*#define PACKET_LIB_QUIET*/
/* If these 2 are not defined, the corresponding config setting is used */
/* #define USE_DHCP 0 */
/* #define USE_AUTOIP 0 */
/* #define USE_PCAPIF 1 */
#define LWIP_PORT_INIT_IPADDR(addr) IP4_ADDR((addr), 192,168,1,200)
#define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), 192,168,1,1)
#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255,255,255,0)
/* remember to change this MAC address to suit your needs!
the last octet will be increased by netif->num for each netif */
#define LWIP_MAC_ADDR_BASE {0x00,0x01,0x02,0x03,0x04,0x05}
/* #define USE_SLIPIF 0 */
/* #define SIO_USE_COMPORT 0 */
#ifdef USE_SLIPIF
#if USE_SLIPIF
#define LWIP_PORT_INIT_SLIP1_IPADDR(addr) IP4_ADDR((addr), 192, 168, 2, 2)
#define LWIP_PORT_INIT_SLIP1_GW(addr) IP4_ADDR((addr), 192, 168, 2, 1)
#define LWIP_PORT_INIT_SLIP1_NETMASK(addr) IP4_ADDR((addr), 255, 255, 255, 0)
#if USE_SLIPIF > 1
#define LWIP_PORT_INIT_SLIP2_IPADDR(addr) IP4_ADDR((addr), 192, 168, 2, 1)
#define LWIP_PORT_INIT_SLIP2_GW(addr) IP4_ADDR((addr), 0, 0, 0, 0)
#define LWIP_PORT_INIT_SLIP2_NETMASK(addr) IP4_ADDR((addr), 255, 255, 255, 0)*/
#endif /* USE_SLIPIF > 1 */
#endif /* USE_SLIPIF */
#endif /* USE_SLIPIF */
/* configuration for applications */
#define LWIP_CHARGEN_APP 0
#define LWIP_DNS_APP 0
#define LWIP_HTTPD_APP 0
/* Set this to 1 to use the netconn http server,
* otherwise the raw api server will be used. */
/*#define LWIP_HTTPD_APP_NETCONN */
#define LWIP_NETBIOS_APP 0
#define LWIP_NETIO_APP 0
#define LWIP_MDNS_APP 0
#define LWIP_MQTT_APP 0
#define LWIP_PING_APP 0
#define LWIP_RTP_APP 0
#define LWIP_SHELL_APP 0
#define LWIP_SNMP_APP 0
#define LWIP_SNTP_APP 0
#define LWIP_SOCKET_EXAMPLES_APP 0
#define LWIP_TCPECHO_APP 0
/* Set this to 1 to use the netconn tcpecho server,
* otherwise the raw api server will be used. */
/*#define LWIP_TCPECHO_APP_NETCONN */
#define LWIP_TFTP_APP 0
#define LWIP_TFTP_CLIENT_APP 0
#define LWIP_UDPECHO_APP 0
#define LWIP_LWIPERF_APP 0
/*#define USE_DHCP 1*/
/*#define USE_AUTOIP 1*/
/* define this to your custom application-init function */
/* #define LWIP_APP_INIT my_app_init() */

View File

@@ -1,326 +0,0 @@
/*
* 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 LWIP_LWIPOPTS_H
#define LWIP_LWIPOPTS_H
#ifdef LWIP_OPTTEST_FILE
#include "lwipopts_test.h"
#else /* LWIP_OPTTEST_FILE */
#define LWIP_IPV4 1
#define LWIP_IPV6 1
#define NO_SYS 0
#define LWIP_SOCKET (NO_SYS==0)
#define LWIP_NETCONN (NO_SYS==0)
#define LWIP_NETIF_API (NO_SYS==0)
#define LWIP_IGMP LWIP_IPV4
#define LWIP_ICMP LWIP_IPV4
#define LWIP_SNMP LWIP_UDP
#define MIB2_STATS LWIP_SNMP
#ifdef LWIP_HAVE_MBEDTLS
#define LWIP_SNMP_V3 (LWIP_SNMP)
#endif
#define LWIP_DNS LWIP_UDP
#define LWIP_MDNS_RESPONDER LWIP_UDP
#define LWIP_NUM_NETIF_CLIENT_DATA (LWIP_MDNS_RESPONDER)
#define LWIP_HAVE_LOOPIF 1
#define LWIP_NETIF_LOOPBACK 1
#define LWIP_LOOPBACK_MAX_PBUFS 10
#define TCP_LISTEN_BACKLOG 1
#define LWIP_COMPAT_SOCKETS 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_RCVBUF 1
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
#ifdef LWIP_DEBUG
#define LWIP_DBG_MIN_LEVEL 0
#define PPP_DEBUG LWIP_DBG_OFF
#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 DNS_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_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
#endif
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
/* ---------- 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. */
/* MSVC port: intel processors don't need 4-byte alignment,
but are faster that way! */
#define MEM_ALIGNMENT 4U
/* 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 10240
/* 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 16
/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
per active RAW "connection". */
#define MEMP_NUM_RAW_PCB 3
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
per active UDP "connection". */
#define MEMP_NUM_UDP_PCB 8
/* MEMP_NUM_TCP_PCB: the number of simultaneously active TCP
connections. */
#define MEMP_NUM_TCP_PCB 5
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 8
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
segments. */
#define MEMP_NUM_TCP_SEG 16
/* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active
timeouts. */
#define MEMP_NUM_SYS_TIMEOUT 17
/* 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 2
/* MEMP_NUM_NETCONN: the number of struct netconns. */
#define MEMP_NUM_NETCONN 12
/* MEMP_NUM_TCPIP_MSG_*: 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_API 16
#define MEMP_NUM_TCPIP_MSG_INPKT 16
/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE 120
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE 256
/** SYS_LIGHTWEIGHT_PROT
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
* for certain critical regions during buffer allocation, deallocation and memory
* allocation and deallocation.
*/
#define SYS_LIGHTWEIGHT_PROT (NO_SYS==0)
/* ---------- TCP options ---------- */
#define LWIP_TCP 1
#define TCP_TTL 255
#define LWIP_ALTCP (LWIP_TCP)
#ifdef LWIP_HAVE_MBEDTLS
#define LWIP_ALTCP_TLS (LWIP_TCP)
#define LWIP_ALTCP_TLS_MBEDTLS (LWIP_TCP)
#endif
/* 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 1024
/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF 2048
/* TCP sender buffer space (pbufs). This must be at least = 2 *
TCP_SND_BUF/TCP_MSS for things to work. */
#define TCP_SND_QUEUELEN (4 * TCP_SND_BUF/TCP_MSS)
/* TCP writable space (bytes). This must be less than or equal
to TCP_SND_BUF. It is the amount of space which must be
available in the tcp snd_buf for select to return writable */
#define TCP_SNDLOWAT (TCP_SND_BUF/2)
/* TCP receive window. */
#define TCP_WND (20 * 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 LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_QUEUEING 1
/* ---------- 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 1
/* IP reassembly and segmentation.These are orthogonal even
* if they both deal with IP fragments */
#define IP_REASSEMBLY 1
#define IP_REASS_MAX_PBUFS (10 * ((1500 + PBUF_POOL_BUFSIZE - 1) / PBUF_POOL_BUFSIZE))
#define MEMP_NUM_REASSDATA IP_REASS_MAX_PBUFS
#define IP_FRAG 1
#define IPV6_FRAG_COPYHEADER 1
/* ---------- ICMP options ---------- */
#define ICMP_TTL 255
/* ---------- DHCP options ---------- */
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
interfaces. */
#define LWIP_DHCP LWIP_UDP
/* 1 if you want to do an ARP check on the offered address
(recommended). */
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
/* ---------- AUTOIP options ------- */
#define LWIP_AUTOIP (LWIP_DHCP)
#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP)
/* ---------- UDP options ---------- */
#define LWIP_UDP 1
#define LWIP_UDPLITE LWIP_UDP
#define UDP_TTL 255
/* ---------- RAW options ---------- */
#define LWIP_RAW 1
/* ---------- Statistics options ---------- */
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 1
#if LWIP_STATS
#define LINK_STATS 1
#define IP_STATS 1
#define ICMP_STATS 1
#define IGMP_STATS 1
#define IPFRAG_STATS 1
#define UDP_STATS 1
#define TCP_STATS 1
#define MEM_STATS 1
#define MEMP_STATS 1
#define PBUF_STATS 1
#define SYS_STATS 1
#endif /* LWIP_STATS */
/* ---------- NETBIOS options ---------- */
#define LWIP_NETBIOS_RESPOND_NAME_QUERY 1
/* ---------- PPP options ---------- */
#define PPP_SUPPORT 1 /* Set > 0 for PPP */
#if PPP_SUPPORT
#define NUM_PPP 1 /* Max PPP sessions. */
/* Select modules to enable. Ideally these would be set in the makefile but
* we're limited by the command line length so you need to modify the settings
* in this file.
*/
#define PPPOE_SUPPORT 1
#define PPPOS_SUPPORT 1
#define PAP_SUPPORT 1 /* Set > 0 for PAP. */
#define CHAP_SUPPORT 1 /* Set > 0 for CHAP. */
#define MSCHAP_SUPPORT 0 /* Set > 0 for MSCHAP */
#define CBCP_SUPPORT 0 /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
#define CCP_SUPPORT 0 /* Set > 0 for CCP */
#define VJ_SUPPORT 0 /* Set > 0 for VJ header compression. */
#define MD5_SUPPORT 1 /* Set > 0 for MD5 (see also CHAP) */
#endif /* PPP_SUPPORT */
#endif /* LWIP_OPTTEST_FILE */
/* The following defines must be done even in OPTTEST mode: */
#if !defined(NO_SYS) || !NO_SYS /* default is 0 */
void sys_check_core_locking(void);
#define LWIP_ASSERT_CORE_LOCKED() sys_check_core_locking()
#endif
#ifndef LWIP_PLATFORM_ASSERT
/* Define LWIP_PLATFORM_ASSERT to something to catch missing stdio.h includes */
void lwip_example_app_platform_assert(const char *msg, int line, const char *file);
#define LWIP_PLATFORM_ASSERT(x) lwip_example_app_platform_assert(x, __LINE__, __FILE__)
#endif
#endif /* LWIP_LWIPOPTS_H */

View File

@@ -1,20 +0,0 @@
/* OPTIONAL: Pools to replace heap allocation
* Optional: Pools can be used instead of the heap for mem_malloc. If
* so, these should be defined here, in increasing order according to
* the pool element size.
*
* LWIP_MALLOC_MEMPOOL(number_elements, element_size)
*/
#if MEM_USE_POOLS
LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL(100, 256)
LWIP_MALLOC_MEMPOOL(50, 512)
LWIP_MALLOC_MEMPOOL(20, 1024)
LWIP_MALLOC_MEMPOOL(20, 1536)
LWIP_MALLOC_MEMPOOL_END
#endif /* MEM_USE_POOLS */
/* Optional: Your custom pools can go here if you would like to use
* lwIP's memory pools for anything else.
*/
LWIP_MEMPOOL(SYS_MBOX, 22, 100, "SYS_MBOX")

View File

@@ -1,6 +0,0 @@
#ifdef _MSC_VER
#pragma warning (disable: 4242) /* PPP only: conversion from 'x' to 'y', possible loss of data */
#pragma warning (disable: 4244) /* PPP only: conversion from 'x' to 'y', possible loss of data (again?) */
#pragma warning (disable: 4310) /* PPP only: cast truncates constant value */
#pragma warning (disable: 4706) /* PPP only: assignment within conditional expression */
#endif /* MSC_VER */

View File

@@ -1,773 +0,0 @@
/*
* Copyright (c) 2001,2002 Florian Schulze.
* 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. Neither the name of the authors nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
*
* test.c - This file is part of lwIP test
*
*/
/* C runtime includes */
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
/* lwIP core includes */
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "lwip/timeouts.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/init.h"
#include "lwip/tcpip.h"
#include "lwip/netif.h"
#include "lwip/api.h"
#include "lwip/tcp.h"
#include "lwip/udp.h"
#include "lwip/dns.h"
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
/* lwIP netif includes */
#include "lwip/etharp.h"
#include "netif/ethernet.h"
/* applications includes */
#include "lwip/apps/netbiosns.h"
#include "lwip/apps/httpd.h"
#include "apps/httpserver/httpserver-netconn.h"
#include "apps/netio/netio.h"
#include "apps/ping/ping.h"
#include "apps/rtp/rtp.h"
#include "apps/chargen/chargen.h"
#include "apps/shell/shell.h"
#include "apps/tcpecho/tcpecho.h"
#include "apps/udpecho/udpecho.h"
#include "apps/tcpecho_raw/tcpecho_raw.h"
#include "apps/socket_examples/socket_examples.h"
#include "examples/lwiperf/lwiperf_example.h"
#include "examples/mdns/mdns_example.h"
#include "examples/snmp/snmp_example.h"
#include "examples/tftp/tftp_example.h"
#include "examples/sntp/sntp_example.h"
#include "examples/mqtt/mqtt_example.h"
#include "examples/httpd/cgi_example/cgi_example.h"
#include "examples/httpd/fs_example/fs_example.h"
#include "examples/httpd/https_example/https_example.h"
#include "examples/httpd/ssi_example/ssi_example.h"
#include "default_netif.h"
#if NO_SYS
/* ... then we need information about the timer intervals: */
#include "lwip/ip4_frag.h"
#include "lwip/igmp.h"
#endif /* NO_SYS */
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT
/* PPP includes */
#include "lwip/sio.h"
#include "netif/ppp/pppapi.h"
#include "netif/ppp/pppos.h"
#include "netif/ppp/pppoe.h"
#if !NO_SYS && !LWIP_PPP_API
#error With NO_SYS==0, LWIP_PPP_API==1 is required.
#endif
#endif /* PPP_SUPPORT */
/* include the port-dependent configuration */
#include "lwipcfg.h"
#ifndef LWIP_EXAMPLE_APP_ABORT
#define LWIP_EXAMPLE_APP_ABORT() 0
#endif
/** Define this to 1 to enable a port-specific ethernet interface as default interface. */
#ifndef USE_DEFAULT_ETH_NETIF
#define USE_DEFAULT_ETH_NETIF 1
#endif
/** Define this to 1 to enable a PPP interface. */
#ifndef USE_PPP
#define USE_PPP 0
#endif
/** Define this to 1 or 2 to support 1 or 2 SLIP interfaces. */
#ifndef USE_SLIPIF
#define USE_SLIPIF 0
#endif
/** Use an ethernet adapter? Default to enabled if port-specific ethernet netif or PPPoE are used. */
#ifndef USE_ETHERNET
#define USE_ETHERNET (USE_DEFAULT_ETH_NETIF || PPPOE_SUPPORT)
#endif
/** Use an ethernet adapter for TCP/IP? By default only if port-specific ethernet netif is used. */
#ifndef USE_ETHERNET_TCPIP
#define USE_ETHERNET_TCPIP (USE_DEFAULT_ETH_NETIF)
#endif
#if USE_SLIPIF
#include <netif/slipif.h>
#endif /* USE_SLIPIF */
#ifndef USE_DHCP
#define USE_DHCP LWIP_DHCP
#endif
#ifndef USE_AUTOIP
#define USE_AUTOIP LWIP_AUTOIP
#endif
/* global variables for netifs */
#if USE_ETHERNET
#if LWIP_DHCP
/* dhcp struct for the ethernet netif */
static struct dhcp netif_dhcp;
#endif /* LWIP_DHCP */
#if LWIP_AUTOIP
/* autoip struct for the ethernet netif */
static struct autoip netif_autoip;
#endif /* LWIP_AUTOIP */
#endif /* USE_ETHERNET */
#if USE_PPP
/* THE PPP PCB */
static ppp_pcb *ppp;
/* THE PPP interface */
static struct netif ppp_netif;
/* THE PPP descriptor */
static u8_t sio_idx = 0;
static sio_fd_t ppp_sio;
#endif /* USE_PPP */
#if USE_SLIPIF
static struct netif slipif1;
#if USE_SLIPIF > 1
static struct netif slipif2;
#endif /* USE_SLIPIF > 1 */
#endif /* USE_SLIPIF */
#if USE_PPP
static void
pppLinkStatusCallback(ppp_pcb *pcb, int errCode, void *ctx)
{
struct netif *pppif = ppp_netif(pcb);
LWIP_UNUSED_ARG(ctx);
switch(errCode) {
case PPPERR_NONE: { /* No error. */
printf("pppLinkStatusCallback: PPPERR_NONE\n");
#if LWIP_IPV4
printf(" our_ipaddr = %s\n", ip4addr_ntoa(netif_ip4_addr(pppif)));
printf(" his_ipaddr = %s\n", ip4addr_ntoa(netif_ip4_gw(pppif)));
printf(" netmask = %s\n", ip4addr_ntoa(netif_ip4_netmask(pppif)));
#endif /* LWIP_IPV4 */
#if LWIP_DNS
printf(" dns1 = %s\n", ipaddr_ntoa(dns_getserver(0)));
printf(" dns2 = %s\n", ipaddr_ntoa(dns_getserver(1)));
#endif /* LWIP_DNS */
#if PPP_IPV6_SUPPORT
printf(" our6_ipaddr = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0)));
#endif /* PPP_IPV6_SUPPORT */
break;
}
case PPPERR_PARAM: { /* Invalid parameter. */
printf("pppLinkStatusCallback: PPPERR_PARAM\n");
break;
}
case PPPERR_OPEN: { /* Unable to open PPP session. */
printf("pppLinkStatusCallback: PPPERR_OPEN\n");
break;
}
case PPPERR_DEVICE: { /* Invalid I/O device for PPP. */
printf("pppLinkStatusCallback: PPPERR_DEVICE\n");
break;
}
case PPPERR_ALLOC: { /* Unable to allocate resources. */
printf("pppLinkStatusCallback: PPPERR_ALLOC\n");
break;
}
case PPPERR_USER: { /* User interrupt. */
printf("pppLinkStatusCallback: PPPERR_USER\n");
break;
}
case PPPERR_CONNECT: { /* Connection lost. */
printf("pppLinkStatusCallback: PPPERR_CONNECT\n");
break;
}
case PPPERR_AUTHFAIL: { /* Failed authentication challenge. */
printf("pppLinkStatusCallback: PPPERR_AUTHFAIL\n");
break;
}
case PPPERR_PROTOCOL: { /* Failed to meet protocol. */
printf("pppLinkStatusCallback: PPPERR_PROTOCOL\n");
break;
}
case PPPERR_PEERDEAD: { /* Connection timeout */
printf("pppLinkStatusCallback: PPPERR_PEERDEAD\n");
break;
}
case PPPERR_IDLETIMEOUT: { /* Idle Timeout */
printf("pppLinkStatusCallback: PPPERR_IDLETIMEOUT\n");
break;
}
case PPPERR_CONNECTTIME: { /* Max connect time reached */
printf("pppLinkStatusCallback: PPPERR_CONNECTTIME\n");
break;
}
case PPPERR_LOOPBACK: { /* Loopback detected */
printf("pppLinkStatusCallback: PPPERR_LOOPBACK\n");
break;
}
default: {
printf("pppLinkStatusCallback: unknown errCode %d\n", errCode);
break;
}
}
}
#if PPPOS_SUPPORT
static u32_t
ppp_output_cb(ppp_pcb *pcb, const void *data, u32_t len, void *ctx)
{
LWIP_UNUSED_ARG(pcb);
LWIP_UNUSED_ARG(ctx);
return sio_write(ppp_sio, (const u8_t*)data, len);
}
#endif /* PPPOS_SUPPORT */
#endif /* USE_PPP */
#if LWIP_NETIF_STATUS_CALLBACK
static void
status_callback(struct netif *state_netif)
{
if (netif_is_up(state_netif)) {
#if LWIP_IPV4
printf("status_callback==UP, local interface IP is %s\n", ip4addr_ntoa(netif_ip4_addr(state_netif)));
#else
printf("status_callback==UP\n");
#endif
} else {
printf("status_callback==DOWN\n");
}
}
#endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
static void
link_callback(struct netif *state_netif)
{
if (netif_is_link_up(state_netif)) {
printf("link_callback==UP\n");
} else {
printf("link_callback==DOWN\n");
}
}
#endif /* LWIP_NETIF_LINK_CALLBACK */
/* This function initializes all network interfaces */
static void
test_netif_init(void)
{
#if LWIP_IPV4 && USE_ETHERNET
ip4_addr_t ipaddr, netmask, gw;
#endif /* LWIP_IPV4 && USE_ETHERNET */
#if USE_SLIPIF
u8_t num_slip1 = 0;
#if LWIP_IPV4
ip4_addr_t ipaddr_slip1, netmask_slip1, gw_slip1;
#endif
#if USE_SLIPIF > 1
u8_t num_slip2 = 1;
#if LWIP_IPV4
ip4_addr_t ipaddr_slip2, netmask_slip2, gw_slip2;
#endif
#endif /* USE_SLIPIF > 1 */
#endif /* USE_SLIPIF */
#if USE_DHCP || USE_AUTOIP
err_t err;
#endif
#if USE_PPP
const char *username = NULL, *password = NULL;
#ifdef PPP_USERNAME
username = PPP_USERNAME;
#endif
#ifdef PPP_PASSWORD
password = PPP_PASSWORD;
#endif
printf("ppp_connect: COM%d\n", (int)sio_idx);
#if PPPOS_SUPPORT
ppp_sio = sio_open(sio_idx);
if (ppp_sio == NULL) {
printf("sio_open error\n");
} else {
ppp = pppos_create(&ppp_netif, ppp_output_cb, pppLinkStatusCallback, NULL);
if (ppp == NULL) {
printf("pppos_create error\n");
} else {
ppp_set_auth(ppp, PPPAUTHTYPE_ANY, username, password);
ppp_connect(ppp, 0);
}
}
#endif /* PPPOS_SUPPORT */
#endif /* USE_PPP */
#if USE_ETHERNET
#if LWIP_IPV4
ip4_addr_set_zero(&gw);
ip4_addr_set_zero(&ipaddr);
ip4_addr_set_zero(&netmask);
#if USE_ETHERNET_TCPIP
#if USE_DHCP
printf("Starting lwIP, local interface IP is dhcp-enabled\n");
#elif USE_AUTOIP
printf("Starting lwIP, local interface IP is autoip-enabled\n");
#else /* USE_DHCP */
LWIP_PORT_INIT_GW(&gw);
LWIP_PORT_INIT_IPADDR(&ipaddr);
LWIP_PORT_INIT_NETMASK(&netmask);
printf("Starting lwIP, local interface IP is %s\n", ip4addr_ntoa(&ipaddr));
#endif /* USE_DHCP */
#endif /* USE_ETHERNET_TCPIP */
#else /* LWIP_IPV4 */
printf("Starting lwIP, IPv4 disable\n");
#endif /* LWIP_IPV4 */
#if LWIP_IPV4
init_default_netif(&ipaddr, &netmask, &gw);
#else
init_default_netif();
#endif
#if LWIP_IPV6
netif_create_ip6_linklocal_address(netif_default, 1);
printf("ip6 linklocal address: %s\n", ip6addr_ntoa(netif_ip6_addr(netif_default, 0)));
#endif /* LWIP_IPV6 */
#if LWIP_NETIF_STATUS_CALLBACK
netif_set_status_callback(netif_default, status_callback);
#endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
netif_set_link_callback(netif_default, link_callback);
#endif /* LWIP_NETIF_LINK_CALLBACK */
#if USE_ETHERNET_TCPIP
#if LWIP_AUTOIP
autoip_set_struct(netif_default, &netif_autoip);
#endif /* LWIP_AUTOIP */
#if LWIP_DHCP
dhcp_set_struct(netif_default, &netif_dhcp);
#endif /* LWIP_DHCP */
netif_set_up(netif_default);
#if USE_DHCP
err = dhcp_start(netif_default);
LWIP_ASSERT("dhcp_start failed", err == ERR_OK);
#elif USE_AUTOIP
err = autoip_start(netif_default);
LWIP_ASSERT("autoip_start failed", err == ERR_OK);
#endif /* USE_DHCP */
#else /* USE_ETHERNET_TCPIP */
/* Use ethernet for PPPoE only */
netif.flags &= ~(NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP); /* no ARP */
netif.flags |= NETIF_FLAG_ETHERNET; /* but pure ethernet */
#endif /* USE_ETHERNET_TCPIP */
#if USE_PPP && PPPOE_SUPPORT
/* start PPPoE after ethernet netif is added! */
ppp = pppoe_create(&ppp_netif, netif_default, NULL, NULL, pppLinkStatusCallback, NULL);
if (ppp == NULL) {
printf("pppoe_create error\n");
} else {
ppp_set_auth(ppp, PPPAUTHTYPE_ANY, username, password);
ppp_connect(ppp, 0);
}
#endif /* USE_PPP && PPPOE_SUPPORT */
#endif /* USE_ETHERNET */
#if USE_SLIPIF
#if LWIP_IPV4
#define SLIP1_ADDRS &ipaddr_slip1, &netmask_slip1, &gw_slip1,
LWIP_PORT_INIT_SLIP1_IPADDR(&ipaddr_slip1);
LWIP_PORT_INIT_SLIP1_GW(&gw_slip1);
LWIP_PORT_INIT_SLIP1_NETMASK(&netmask_slip1);
printf("Starting lwIP slipif, local interface IP is %s\n", ip4addr_ntoa(&ipaddr_slip1));
#else
#define SLIP1_ADDRS
printf("Starting lwIP slipif\n");
#endif
#if defined(SIO_USE_COMPORT) && SIO_USE_COMPORT
num_slip1++; /* COM ports cannot be 0-based */
#endif
netif_add(&slipif1, SLIP1_ADDRS &num_slip1, slipif_init, ip_input);
#if !USE_ETHERNET
netif_set_default(&slipif1);
#endif /* !USE_ETHERNET */
#if LWIP_IPV6
netif_create_ip6_linklocal_address(&slipif1, 1);
printf("SLIP ip6 linklocal address: %s\n", ip6addr_ntoa(netif_ip6_addr(&slipif1, 0)));
#endif /* LWIP_IPV6 */
#if LWIP_NETIF_STATUS_CALLBACK
netif_set_status_callback(&slipif1, status_callback);
#endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
netif_set_link_callback(&slipif1, link_callback);
#endif /* LWIP_NETIF_LINK_CALLBACK */
netif_set_up(&slipif1);
#if USE_SLIPIF > 1
#if LWIP_IPV4
#define SLIP2_ADDRS &ipaddr_slip2, &netmask_slip2, &gw_slip2,
LWIP_PORT_INIT_SLIP2_IPADDR(&ipaddr_slip2);
LWIP_PORT_INIT_SLIP2_GW(&gw_slip2);
LWIP_PORT_INIT_SLIP2_NETMASK(&netmask_slip2);
printf("Starting lwIP SLIP if #2, local interface IP is %s\n", ip4addr_ntoa(&ipaddr_slip2));
#else
#define SLIP2_ADDRS
printf("Starting lwIP SLIP if #2\n");
#endif
#if defined(SIO_USE_COMPORT) && SIO_USE_COMPORT
num_slip2++; /* COM ports cannot be 0-based */
#endif
netif_add(&slipif2, SLIP2_ADDRS &num_slip2, slipif_init, ip_input);
#if LWIP_IPV6
netif_create_ip6_linklocal_address(&slipif1, 1);
printf("SLIP2 ip6 linklocal address: ");
ip6_addr_debug_print(0xFFFFFFFF & ~LWIP_DBG_HALT, netif_ip6_addr(&slipif2, 0));
printf("\n");
#endif /* LWIP_IPV6 */
#if LWIP_NETIF_STATUS_CALLBACK
netif_set_status_callback(&slipif2, status_callback);
#endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
netif_set_link_callback(&slipif2, link_callback);
#endif /* LWIP_NETIF_LINK_CALLBACK */
netif_set_up(&slipif2);
#endif /* USE_SLIPIF > 1*/
#endif /* USE_SLIPIF */
}
#if LWIP_DNS_APP && LWIP_DNS
static void
dns_found(const char *name, const ip_addr_t *addr, void *arg)
{
LWIP_UNUSED_ARG(arg);
printf("%s: %s\n", name, addr ? ipaddr_ntoa(addr) : "<not found>");
}
static void
dns_dorequest(void *arg)
{
const char* dnsname = "3com.com";
ip_addr_t dnsresp;
LWIP_UNUSED_ARG(arg);
if (dns_gethostbyname(dnsname, &dnsresp, dns_found, NULL) == ERR_OK) {
dns_found(dnsname, &dnsresp, NULL);
}
}
#endif /* LWIP_DNS_APP && LWIP_DNS */
/* This function initializes applications */
static void
apps_init(void)
{
#if LWIP_DNS_APP && LWIP_DNS
/* wait until the netif is up (for dhcp, autoip or ppp) */
sys_timeout(5000, dns_dorequest, NULL);
#endif /* LWIP_DNS_APP && LWIP_DNS */
#if LWIP_CHARGEN_APP && LWIP_SOCKET
chargen_init();
#endif /* LWIP_CHARGEN_APP && LWIP_SOCKET */
#if LWIP_PING_APP && LWIP_RAW && LWIP_ICMP
ping_init(&netif_default->gw);
#endif /* LWIP_PING_APP && LWIP_RAW && LWIP_ICMP */
#if LWIP_NETBIOS_APP && LWIP_UDP
netbiosns_init();
#ifndef NETBIOS_LWIP_NAME
#if LWIP_NETIF_HOSTNAME
netbiosns_set_name(netif_default->hostname);
#else
netbiosns_set_name("NETBIOSLWIPDEV");
#endif
#endif
#endif /* LWIP_NETBIOS_APP && LWIP_UDP */
#if LWIP_HTTPD_APP && LWIP_TCP
#ifdef LWIP_HTTPD_APP_NETCONN
http_server_netconn_init();
#else /* LWIP_HTTPD_APP_NETCONN */
#if defined(LWIP_HTTPD_EXAMPLE_CUSTOMFILES) && LWIP_HTTPD_EXAMPLE_CUSTOMFILES && defined(LWIP_HTTPD_EXAMPLE_CUSTOMFILES_ROOTDIR)
fs_ex_init(LWIP_HTTPD_EXAMPLE_CUSTOMFILES_ROOTDIR);
#endif
httpd_init();
#if defined(LWIP_HTTPD_EXAMPLE_SSI_SIMPLE) && LWIP_HTTPD_EXAMPLE_SSI_SIMPLE
ssi_ex_init();
#endif
#if defined(LWIP_HTTPD_EXAMPLE_CGI_SIMPLE) && LWIP_HTTPD_EXAMPLE_CGI_SIMPLE
cgi_ex_init();
#endif
#if defined(LWIP_HTTPD_EXAMPLE_HTTPS) && LWIP_HTTPD_EXAMPLE_HTTPS
https_ex_init();
#endif
#endif /* LWIP_HTTPD_APP_NETCONN */
#endif /* LWIP_HTTPD_APP && LWIP_TCP */
#if LWIP_NETIO_APP && LWIP_TCP
netio_init();
#endif /* LWIP_NETIO_APP && LWIP_TCP */
#if LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP
rtp_init();
#endif /* LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP */
#if LWIP_SHELL_APP && LWIP_NETCONN
shell_init();
#endif /* LWIP_SHELL_APP && LWIP_NETCONN */
#if LWIP_TCPECHO_APP
#if LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN)
tcpecho_init();
#else /* LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN) */
tcpecho_raw_init();
#endif
#endif /* LWIP_TCPECHO_APP && LWIP_NETCONN */
#if LWIP_UDPECHO_APP && LWIP_NETCONN
udpecho_init();
#endif /* LWIP_UDPECHO_APP && LWIP_NETCONN */
#if LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET
socket_examples_init();
#endif /* LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET */
#if LWIP_MDNS_APP
mdns_example_init();
#endif
#if LWIP_SNMP_APP
snmp_example_init();
#endif
#if LWIP_SNTP_APP
sntp_example_init();
#endif
#if LWIP_TFTP_APP
tftp_example_init_server();
#endif
#if LWIP_TFTP_CLIENT_APP
tftp_example_init_client();
#endif
#if LWIP_LWIPERF_APP
lwiperf_example_init();
#endif
#if LWIP_MQTT_APP
mqtt_example_init();
#endif
#ifdef LWIP_APP_INIT
LWIP_APP_INIT();
#endif
}
/* This function initializes this lwIP test. When NO_SYS=1, this is done in
* the main_loop context (there is no other one), when NO_SYS=0, this is done
* in the tcpip_thread context */
static void
test_init(void * arg)
{ /* remove compiler warning */
#if NO_SYS
LWIP_UNUSED_ARG(arg);
#else /* NO_SYS */
sys_sem_t *init_sem;
LWIP_ASSERT("arg != NULL", arg != NULL);
init_sem = (sys_sem_t*)arg;
#endif /* NO_SYS */
/* init randomizer again (seed per thread) */
srand((unsigned int)time(NULL));
/* init network interfaces */
test_netif_init();
/* init apps */
apps_init();
#if !NO_SYS
sys_sem_signal(init_sem);
#endif /* !NO_SYS */
}
/* This is somewhat different to other ports: we have a main loop here:
* a dedicated task that waits for packets to arrive. This would normally be
* done from interrupt context with embedded hardware, but we don't get an
* interrupt in windows for that :-) */
static void
main_loop(void)
{
#if !NO_SYS
err_t err;
sys_sem_t init_sem;
#endif /* NO_SYS */
#if USE_PPP
#if !USE_ETHERNET
int count;
u8_t rxbuf[1024];
#endif
volatile int callClosePpp = 0;
#endif /* USE_PPP */
/* initialize lwIP stack, network interfaces and applications */
#if NO_SYS
lwip_init();
test_init(NULL);
#else /* NO_SYS */
err = sys_sem_new(&init_sem, 0);
LWIP_ASSERT("failed to create init_sem", err == ERR_OK);
LWIP_UNUSED_ARG(err);
tcpip_init(test_init, &init_sem);
/* we have to wait for initialization to finish before
* calling update_adapter()! */
sys_sem_wait(&init_sem);
sys_sem_free(&init_sem);
#endif /* NO_SYS */
#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
netconn_thread_init();
#endif
/* MAIN LOOP for driver update (and timers if NO_SYS) */
while (!LWIP_EXAMPLE_APP_ABORT()) {
#if NO_SYS
/* handle timers (already done in tcpip.c when NO_SYS=0) */
sys_check_timeouts();
#endif /* NO_SYS */
#if USE_ETHERNET
default_netif_poll();
#else /* USE_ETHERNET */
/* try to read characters from serial line and pass them to PPPoS */
count = sio_read(ppp_sio, (u8_t*)rxbuf, 1024);
if(count > 0) {
pppos_input(ppp, rxbuf, count);
} else {
/* nothing received, give other tasks a chance to run */
sys_msleep(1);
}
#endif /* USE_ETHERNET */
#if USE_SLIPIF
slipif_poll(&slipif1);
#if USE_SLIPIF > 1
slipif_poll(&slipif2);
#endif /* USE_SLIPIF > 1 */
#endif /* USE_SLIPIF */
#if ENABLE_LOOPBACK && !LWIP_NETIF_LOOPBACK_MULTITHREADING
/* check for loopback packets on all netifs */
netif_poll_all();
#endif /* ENABLE_LOOPBACK && !LWIP_NETIF_LOOPBACK_MULTITHREADING */
#if USE_PPP
{
int do_hup = 0;
if(do_hup) {
ppp_close(ppp, 1);
do_hup = 0;
}
}
if(callClosePpp && ppp) {
/* make sure to disconnect PPP before stopping the program... */
callClosePpp = 0;
#if NO_SYS
ppp_close(ppp, 0);
#else
pppapi_close(ppp, 0);
#endif
ppp = NULL;
}
#endif /* USE_PPP */
}
#if USE_PPP
if(ppp) {
u32_t started;
printf("Closing PPP connection...\n");
/* make sure to disconnect PPP before stopping the program... */
#if NO_SYS
ppp_close(ppp, 0);
#else
pppapi_close(ppp, 0);
#endif
ppp = NULL;
/* Wait for some time to let PPP finish... */
started = sys_now();
do
{
#if USE_ETHERNET
default_netif_poll();
#endif
/* @todo: need a better check here: only wait until PPP is down */
} while(sys_now() - started < 5000);
}
#endif /* USE_PPP */
#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
netconn_thread_cleanup();
#endif
#if USE_ETHERNET
default_netif_shutdown();
#endif /* USE_ETHERNET */
}
#if USE_PPP && PPPOS_SUPPORT
int main(int argc, char **argv)
#else /* USE_PPP && PPPOS_SUPPORT */
int main(void)
#endif /* USE_PPP && PPPOS_SUPPORT */
{
#if USE_PPP && PPPOS_SUPPORT
if(argc > 1) {
sio_idx = (u8_t)atoi(argv[1]);
}
printf("Using serial port %d for PPP\n", sio_idx);
#endif /* USE_PPP && PPPOS_SUPPORT */
/* no stdio-buffering, please! */
setvbuf(stdout, NULL,_IONBF, 0);
main_loop();
return 0;
}
/* This function is only required to prevent arch.h including stdio.h
* (which it does if LWIP_PLATFORM_ASSERT is undefined)
*/
void lwip_example_app_platform_assert(const char *msg, int line, const char *file)
{
printf("Assertion \"%s\" failed at line %d in %s\n", msg, line, file);
fflush(NULL);
abort();
}

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 1
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP 1
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 1
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 1
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 0
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 1
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP LWIP_UDP
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 1
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 1
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 1
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 1
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP LWIP_UDP
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 1
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 1
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 0
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 0
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP 0
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 1
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 1
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 1
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,4 +0,0 @@
#include "test_configs/opt_dualstack.h"
#undef LWIP_TCP
#define LWIP_TCP 0

View File

@@ -1,4 +0,0 @@
#include "test_configs/opt_ipv4only.h"
#undef LWIP_TCP
#define LWIP_TCP 0

View File

@@ -1,4 +0,0 @@
#include "test_configs/opt_ipv6only.h"
#undef LWIP_TCP
#define LWIP_TCP 0

View File

@@ -1,4 +0,0 @@
#include "test_configs/opt_dualstack.h"
#undef LWIP_UDP
#define LWIP_UDP 0

View File

@@ -1,4 +0,0 @@
#include "test_configs/opt_ipv4only.h"
#undef LWIP_UDP
#define LWIP_UDP 0

View File

@@ -1,4 +0,0 @@
#include "test_configs/opt_ipv6only.h"
#undef LWIP_UDP
#define LWIP_UDP 0

View File

@@ -1,2 +0,0 @@
/* test and empty lwipopts.h file */

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 1
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP 1
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 0
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 0
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 1
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 1
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP 1
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 0
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 0
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 0
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,295 +0,0 @@
/* test an lwipopts.h file with default contents */
#define NO_SYS 0
#define NO_SYS_NO_TIMERS 0
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 1
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
#define MEM_ALIGNMENT 1
#define MEM_SIZE 1600
#define MEMP_OVERFLOW_CHECK 0
#define MEMP_SANITY_CHECK 0
#define MEM_OVERFLOW_CHECK 0
#define MEM_SANITY_CHECK 0
#define MEM_USE_POOLS 0
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
#define MEMP_USE_CUSTOM_POOLS 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
/*#define MEMP_NUM_PBUF 16
#define MEMP_NUM_RAW_PCB 4
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 5
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
#define MEMP_NUM_REASSDATA 5
#define MEMP_NUM_FRAG_PBUF 15
#define MEMP_NUM_ARP_QUEUE 30
#define MEMP_NUM_IGMP_GROUP 8
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 2)
#define MEMP_NUM_NETBUF 2
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_SELECT_CB 4
#define MEMP_NUM_TCPIP_MSG_API 8
#define MEMP_NUM_TCPIP_MSG_INPKT 8
#define MEMP_NUM_NETDB 1
#define MEMP_NUM_LOCALHOSTLIST 1
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API*/
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_MAXAGE 300
#define ARP_QUEUEING 0
#define ARP_QUEUE_LEN 3
#define ETHARP_SUPPORT_VLAN 0
#define LWIP_ETHERNET LWIP_ARP
#define ETH_PAD_SIZE 0
#define ETHARP_SUPPORT_STATIC_ENTRIES 0
#define ETHARP_TABLE_MATCH_NETIF !LWIP_SINGLE_NETIF
#define LWIP_IPV4 0
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_OPTIONS_ALLOWED 1
#define IP_REASS_MAXAGE 15
#define IP_REASS_MAX_PBUFS 10
#define IP_DEFAULT_TTL 255
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
#define LWIP_ICMP 1
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP 0
#define LWIP_DHCP_CHECK_LINK_UP 0
#define LWIP_DHCP_BOOTP_FILE 0
#define LWIP_DHCP_GET_NTP_SRV 0
#define LWIP_DHCP_MAX_NTP_SERVERS 1
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP 0
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
#define LWIP_MIB2_CALLBACKS 0
#define LWIP_MULTICAST_TX_OPTIONS ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
#define LWIP_IGMP 0
#define LWIP_DNS 0
#define DNS_TABLE_SIZE 4
#define DNS_MAX_NAME_LENGTH 256
#define DNS_MAX_SERVERS 2
#define DNS_MAX_RETRIES 4
#define DNS_DOES_NAME_CHECK 1
#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#define LWIP_UDP 1
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 1
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 6
#define TCP_QUEUE_OOSEQ (LWIP_TCP)
#define LWIP_TCP_SACK_OUT 0
#define LWIP_TCP_MAX_SACK_NUM 4
#define TCP_MSS 536
#define TCP_CALCULATE_EFF_SEND_MSS 1
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_OOSEQ_MAX_BYTES 0
#define TCP_OOSEQ_BYTES_LIMIT(pcb) TCP_OOSEQ_MAX_BYTES
#define TCP_OOSEQ_MAX_PBUFS 0
#define TCP_OOSEQ_PBUFS_LIMIT(pcb) TCP_OOSEQ_MAX_PBUFS
#define TCP_LISTEN_BACKLOG 0
#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
#define TCP_OVERSIZE TCP_MSS
#define LWIP_TCP_TIMESTAMPS 0
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define LWIP_EVENT_API 0
#define LWIP_CALLBACK_API 1
#define LWIP_WND_SCALE 0
#define TCP_RCV_SCALE 0
#define LWIP_TCP_PCB_NUM_EXT_ARGS 0
#define LWIP_ALTCP 0
#define LWIP_ALTCP_TLS 0
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#define PBUF_LINK_ENCAPSULATION_HLEN 0
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#define LWIP_PBUF_REF_T u8_t
#define LWIP_SINGLE_NETIF 0
#define LWIP_NETIF_HOSTNAME 0
#define LWIP_NETIF_API 0
#define LWIP_NETIF_STATUS_CALLBACK 0
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_REMOVE_CALLBACK 0
#define LWIP_NETIF_HWADDRHINT 0
#define LWIP_NETIF_TX_SINGLE_PBUF 0
#define LWIP_NUM_NETIF_CLIENT_DATA 0
#define LWIP_HAVE_LOOPIF (LWIP_NETIF_LOOPBACK && !LWIP_SINGLE_NETIF)
#define LWIP_LOOPIF_MULTICAST 0
#define LWIP_NETIF_LOOPBACK 0
#define LWIP_LOOPBACK_MAX_PBUFS 0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
/*#define TCPIP_THREAD_NAME "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE 0
#define TCPIP_THREAD_PRIO 1
#define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_THREAD_ALIVE()
#define SLIPIF_THREAD_NAME "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE 0
#define SLIPIF_THREAD_PRIO 1
#define DEFAULT_THREAD_NAME "lwIP"
#define DEFAULT_THREAD_STACKSIZE 0
#define DEFAULT_THREAD_PRIO 1
#define DEFAULT_RAW_RECVMBOX_SIZE 0
#define DEFAULT_UDP_RECVMBOX_SIZE 0
#define DEFAULT_TCP_RECVMBOX_SIZE 0
#define DEFAULT_ACCEPTMBOX_SIZE 0*/
#define LWIP_NETCONN 0
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 0
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
#define LWIP_TCP_KEEPALIVE 0
#define LWIP_SO_SNDTIMEO 0
#define LWIP_SO_RCVTIMEO 0
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
#define LWIP_SO_RCVBUF 0
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 0
#define LINK_STATS 1
#define ETHARP_STATS (LWIP_ARP)
#define IP_STATS 1
#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS 1
#define IGMP_STATS (LWIP_IGMP)
#define UDP_STATS (LWIP_UDP)
#define TCP_STATS (LWIP_TCP)
#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
#define SYS_STATS (NO_SYS == 0)
#define IP6_STATS (LWIP_IPV6)
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#define ND6_STATS (LWIP_IPV6)
#define MIB2_STATS 0
#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
#define CHECKSUM_GEN_IP 1
#define CHECKSUM_GEN_UDP 1
#define CHECKSUM_GEN_TCP 1
#define CHECKSUM_GEN_ICMP 1
#define CHECKSUM_GEN_ICMP6 1
#define CHECKSUM_CHECK_IP 1
#define CHECKSUM_CHECK_UDP 1
#define CHECKSUM_CHECK_TCP 1
#define CHECKSUM_CHECK_ICMP 1
#define CHECKSUM_CHECK_ICMP6 1
#define LWIP_CHECKSUM_ON_COPY 0
#define LWIP_IPV6 1
#define IPV6_REASS_MAXAGE 60
#define LWIP_IPV6_SCOPES (LWIP_IPV6 && !LWIP_SINGLE_NETIF)
#define LWIP_IPV6_SCOPES_DEBUG 0
#define LWIP_IPV6_NUM_ADDRESSES 3
#define LWIP_IPV6_FORWARD 0
#define LWIP_IPV6_FRAG 1
#define LWIP_IPV6_REASS (LWIP_IPV6)
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#define LWIP_IPV6_ADDRESS_LIFETIMES (LWIP_IPV6_AUTOCONFIG)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_ICMP6 (LWIP_IPV6)
#define LWIP_ICMP6_DATASIZE 8
#define LWIP_ICMP6_HL 255
#define LWIP_IPV6_MLD (LWIP_IPV6)
#define MEMP_NUM_MLD6_GROUP 4
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#define MEMP_NUM_ND6_QUEUE 20
#define LWIP_ND6_NUM_NEIGHBORS 10
#define LWIP_ND6_NUM_DESTINATIONS 10
#define LWIP_ND6_NUM_PREFIXES 5
#define LWIP_ND6_NUM_ROUTERS 3
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#define LWIP_ND6_REACHABLE_TIME 30000
#define LWIP_ND6_RETRANS_TIMER 1000
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_DHCP6_STATEFUL 0
#define LWIP_IPV6_DHCP6_STATELESS LWIP_IPV6_DHCP6
#define LWIP_DHCP6_GET_NTP_SRV 0
#define LWIP_DHCP6_MAX_NTP_SERVERS 1
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
/* TODO: check hooks */
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_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 SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TIMERS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_FR_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_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
#define LWIP_TESTMODE 0
#define LWIP_PERF 0

View File

@@ -1,107 +0,0 @@
/**
* @file
* HTTPD simple CGI example
*
* This file demonstrates how to add support for basic CGI.
*/
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#include "lwip/opt.h"
#include "cgi_example.h"
#include "lwip/apps/httpd.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include <stdio.h>
#include <string.h>
/** define LWIP_HTTPD_EXAMPLE_CGI_SIMPLE to 1 to enable this cgi example */
#ifndef LWIP_HTTPD_EXAMPLE_CGI_SIMPLE
#define LWIP_HTTPD_EXAMPLE_CGI_SIMPLE 0
#endif
#if LWIP_HTTPD_EXAMPLE_CGI_SIMPLE
#if !LWIP_HTTPD_CGI
#error LWIP_HTTPD_EXAMPLE_CGI_SIMPLE needs LWIP_HTTPD_CGI
#endif
static const char *cgi_handler_basic(int iIndex, int iNumParams, char *pcParam[], char *pcValue[]);
static const tCGI cgi_handlers[] = {
{
"/basic_cgi",
cgi_handler_basic
},
{
"/basic_cgi_2",
cgi_handler_basic
}
};
void
cgi_ex_init(void)
{
http_set_cgi_handlers(cgi_handlers, LWIP_ARRAYSIZE(cgi_handlers));
}
/** This basic CGI function can parse param/value pairs and return an url that
* is sent as a response by httpd.
*
* This example function just checks that the input url has two key value
* parameter pairs: "foo=bar" and "test=123"
* If not, it returns 404
*/
static const char *
cgi_handler_basic(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
LWIP_ASSERT("check index", iIndex < LWIP_ARRAYSIZE(cgi_handlers));
if (iNumParams == 2) {
if (!strcmp(pcParam[0], "foo")) {
if (!strcmp(pcValue[0], "bar")) {
if (!strcmp(pcParam[1], "test")) {
if (!strcmp(pcValue[1], "123")) {
return "/index.html";
}
}
}
}
}
return "/404.html";
}
#endif /* LWIP_HTTPD_EXAMPLE_CGI_SIMPLE */

View File

@@ -1,38 +0,0 @@
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#ifndef LWIP_HDR_HTTP_EXAMPLES_CGI_EXAMPLE
#define LWIP_HDR_HTTP_EXAMPLES_CGI_EXAMPLE
void cgi_ex_init(void);
#endif /* LWIP_HDR_HTTP_EXAMPLES_CGI_EXAMPLE */

View File

@@ -1,28 +0,0 @@
<html>
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head>
<body bgcolor="white" text="black">
<table width="100%">
<tr valign="top">
<td width="80">
<a href="http://www.sics.se/"><img src="/img/sics.gif" border="0" alt="SICS logo" title="SICS logo"/></a>
</td>
<td width="500">
<h1>Login</h1>
<form name="login" action="login.cgi" method="post">
<div>
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="user" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="pass" required>
<button type="submit">Login</button>
</div>
</form>
</td>
<td>
&nbsp;
</td>
</tr>
</table>
</body>
</html>

View File

@@ -1,25 +0,0 @@
<html>
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head>
<body bgcolor="white" text="black">
<table width="100%">
<tr valign="top">
<td width="80">
<a href="http://www.sics.se/"><img src="/img/sics.gif" border="0" alt="SICS logo" title="SICS logo"/></a>
</td>
<td width="500">
<h1>lwIP - A Lightweight TCP/IP Stack</h1>
<p>
Login failed.
</p>
<p>
Click <a href="login.html">here</a> to retry login.
</p>
</td>
<td>
&nbsp;
</td>
</tr>
</table>
</body>
</html>

View File

@@ -1,25 +0,0 @@
<html>
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head>
<body bgcolor="white" text="black">
<table width="100%">
<tr valign="top">
<td width="80">
<a href="http://www.sics.se/"><img src="/img/sics.gif" border="0" alt="SICS logo" title="SICS logo"/></a>
</td>
<td width="500">
<h1>lwIP - A Lightweight TCP/IP Stack</h1>
<p>
Login succeeded, session active.
</p>
<p>
Click <a href="login.html">here</a> to retry login.
</p>
</td>
<td>
&nbsp;
</td>
</tr>
</table>
</body>
</html>

View File

@@ -1,315 +0,0 @@
<html>
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head>
<body bgcolor="white" text="black">
<table width="100%">
<tr valign="top"><td width="80">
<a href="http://www.sics.se/"><img src="/img/sics.gif"
border="0" alt="SICS logo" title="SICS logo"></a>
</td><td width="500">
<h1>lwIP - A Lightweight TCP/IP Stack</h1>
<h1><!--#HellWorl--></h1>
<p>
The web page you are watching was served by a simple web
server running on top of the lightweight TCP/IP stack <a
href="http://www.sics.se/~adam/lwip/">lwIP</a>.
</p>
<p>
This page is here to test SSI, so here is a counter as
an example of content changing for every request:
"<!--#counter-->"
</p>
<p>
And here is an example of a tag result buffer return in
multiple parts: "<!--#MultPart-->"
</p>
<p>
To test LWIP_HTTPD_CGI_SSI, here are the CGI parameters:
<!--#CgiParam-->
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
lwIP is an open source implementation of the TCP/IP
protocol suite that was originally written by <a
href="http://www.sics.se/~adam/lwip/">Adam Dunkels
of the Swedish Institute of Computer Science</a> but now is
being actively developed by a team of developers
distributed world-wide. Since it's release, lwIP has
spurred a lot of interest and has been ported to several
platforms and operating systems. lwIP can be used either
with or without an underlying OS.
</p>
<p>
The focus of the lwIP TCP/IP implementation is to reduce
the RAM usage while still having a full scale TCP. This
makes lwIP suitable for use in embedded systems with tens
of kilobytes of free RAM and room for around 40 kilobytes
of code ROM.
</p>
<p>
More information about lwIP can be found at the lwIP
homepage at <a
href="http://savannah.nongnu.org/projects/lwip/">http://savannah.nongnu.org/projects/lwip/</a>
or at the lwIP wiki at <a
href="http://lwip.wikia.com/">http://lwip.wikia.com/</a>.
</p>
</td><td>
&nbsp;
</td></tr>
</table>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -1,324 +0,0 @@
/**
* @file
* HTTPD custom file system example
*
* This file demonstrates how to add support for an external file system to httpd.
* It provides access to the specified root directory and uses stdio.h file functions
* to read files.
*
* ATTENTION: This implementation is *not* secure: no checks are added to ensure
* files are only read below the specified root directory!
*/
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#include "lwip/opt.h"
#include "fs_example.h"
#include "lwip/apps/fs.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include <stdio.h>
#include <string.h>
/** define LWIP_HTTPD_EXAMPLE_CUSTOMFILES to 1 to enable this file system */
#ifndef LWIP_HTTPD_EXAMPLE_CUSTOMFILES
#define LWIP_HTTPD_EXAMPLE_CUSTOMFILES 0
#endif
/** define LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED to 1 to delay open and read
* as if e.g. reading from external SPI flash */
#ifndef LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
#define LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED 1
#endif
/** define LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ to the number of bytes
* to read to emulate limited transfer buffers and don't read whole files in
* one chunk.
* WARNING: lowering this slows down the connection!
*/
#ifndef LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ
#define LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ 0
#endif
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES
#if !LWIP_HTTPD_CUSTOM_FILES
#error This needs LWIP_HTTPD_CUSTOM_FILES
#endif
#if !LWIP_HTTPD_DYNAMIC_HEADERS
#error This needs LWIP_HTTPD_DYNAMIC_HEADERS
#endif
#if !LWIP_HTTPD_DYNAMIC_FILE_READ
#error This wants to demonstrate read-after-open, so LWIP_HTTPD_DYNAMIC_FILE_READ is required!
#endif
#if !LWIP_HTTPD_FS_ASYNC_READ
#error This needs LWIP_HTTPD_FS_ASYNC_READ
#endif
#if !LWIP_HTTPD_FILE_EXTENSION
#error This needs LWIP_HTTPD_FILE_EXTENSION
#endif
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
#include "lwip/tcpip.h"
#endif
struct fs_custom_data {
FILE *f;
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
int delay_read;
fs_wait_cb callback_fn;
void *callback_arg;
#endif
};
const char* fs_ex_root_dir;
void
fs_ex_init(const char *httpd_root_dir)
{
fs_ex_root_dir = strdup(httpd_root_dir);
}
#if LWIP_HTTPD_CUSTOM_FILES
int
fs_open_custom(struct fs_file *file, const char *name)
{
char full_filename[256];
FILE *f;
snprintf(full_filename, 255, "%s%s", fs_ex_root_dir, name);
full_filename[255] = 0;
f = fopen(full_filename, "rb");
if (f != NULL) {
if (!fseek(f, 0, SEEK_END)) {
int len = (int)ftell(f);
if(!fseek(f, 0, SEEK_SET)) {
struct fs_custom_data *data = (struct fs_custom_data *)mem_malloc(sizeof(struct fs_custom_data));
LWIP_ASSERT("out of memory?", data != NULL);
memset(file, 0, sizeof(struct fs_file));
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
file->len = 0; /* read size delayed */
data->delay_read = 3;
LWIP_UNUSED_ARG(len);
#else
file->len = len;
#endif
file->flags = FS_FILE_FLAGS_HEADER_PERSISTENT;
data->f = f;
file->pextension = data;
return 1;
}
}
fclose(f);
}
return 0;
}
void
fs_close_custom(struct fs_file *file)
{
if (file && file->pextension) {
struct fs_custom_data *data = (struct fs_custom_data *)file->pextension;
if (data->f != NULL) {
fclose(data->f);
data->f = NULL;
}
mem_free(data);
}
}
#if LWIP_HTTPD_FS_ASYNC_READ
u8_t
fs_canread_custom(struct fs_file *file)
{
/* This function is only necessary for asynchronous I/O:
If reading would block, return 0 and implement fs_wait_read_custom() to call the
supplied callback if reading works. */
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
struct fs_custom_data *data;
LWIP_ASSERT("file != NULL", file != NULL);
data = (struct fs_custom_data *)file->pextension;
if (data == NULL) {
/* file transfer has been completed already */
LWIP_ASSERT("transfer complete", file->index == file->len);
return 1;
}
LWIP_ASSERT("data != NULL", data != NULL);
/* This just simulates a simple delay. This delay would normally come e.g. from SPI transfer */
if (data->delay_read == 3) {
/* delayed file size mode */
data->delay_read = 1;
LWIP_ASSERT("", file->len == 0);
if (!fseek(data->f, 0, SEEK_END)) {
int len = (int)ftell(data->f);
if(!fseek(data->f, 0, SEEK_SET)) {
file->len = len; /* read size delayed */
data->delay_read = 1;
return 0;
}
}
/* if we come here, something is wrong with the file */
LWIP_ASSERT("file error", 0);
}
if (data->delay_read == 1) {
/* tell read function to delay further */
}
#endif
LWIP_UNUSED_ARG(file);
return 1;
}
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
static void
fs_example_read_cb(void *arg)
{
struct fs_custom_data *data = (struct fs_custom_data *)arg;
fs_wait_cb callback_fn = data->callback_fn;
void *callback_arg = data->callback_arg;
data->callback_fn = NULL;
data->callback_arg = NULL;
LWIP_ASSERT("no callback_fn", callback_fn != NULL);
callback_fn(callback_arg);
}
#endif
u8_t
fs_wait_read_custom(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg)
{
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
err_t err;
struct fs_custom_data *data = (struct fs_custom_data *)file->pextension;
LWIP_ASSERT("data not set", data != NULL);
data->callback_fn = callback_fn;
data->callback_arg = callback_arg;
err = tcpip_try_callback(fs_example_read_cb, data);
LWIP_ASSERT("out of queue elements?", err == ERR_OK);
LWIP_UNUSED_ARG(err);
#else
LWIP_ASSERT("not implemented in this example configuration", 0);
#endif
LWIP_UNUSED_ARG(file);
LWIP_UNUSED_ARG(callback_fn);
LWIP_UNUSED_ARG(callback_arg);
/* Return
- 0 if ready to read (at least one byte)
- 1 if reading should be delayed (call 'tcpip_callback(callback_fn, callback_arg)' when ready) */
return 1;
}
int
fs_read_async_custom(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg)
{
struct fs_custom_data *data = (struct fs_custom_data *)file->pextension;
FILE *f;
int len;
int read_count = count;
LWIP_ASSERT("data not set", data != NULL);
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_DELAYED
/* This just simulates a delay. This delay would normally come e.g. from SPI transfer */
LWIP_ASSERT("invalid state", data->delay_read >= 0 && data->delay_read <= 2);
if (data->delay_read == 2) {
/* no delay next time */
data->delay_read = 0;
return FS_READ_DELAYED;
} else if (data->delay_read == 1) {
err_t err;
/* execute requested delay */
data->delay_read = 2;
LWIP_ASSERT("duplicate callback request", data->callback_fn == NULL);
data->callback_fn = callback_fn;
data->callback_arg = callback_arg;
err = tcpip_try_callback(fs_example_read_cb, data);
LWIP_ASSERT("out of queue elements?", err == ERR_OK);
LWIP_UNUSED_ARG(err);
return FS_READ_DELAYED;
}
/* execute this read but delay the next one */
data->delay_read = 1;
#endif
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ
read_count = LWIP_MIN(read_count, LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ);
#endif
f = data->f;
len = (int)fread(buffer, 1, read_count, f);
LWIP_UNUSED_ARG(callback_fn);
LWIP_UNUSED_ARG(callback_arg);
file->index += len;
/* Return
- FS_READ_EOF if all bytes have been read
- FS_READ_DELAYED if reading is delayed (call 'tcpip_callback(callback_fn, callback_arg)' when done) */
if (len == 0) {
/* all bytes read already */
return FS_READ_EOF;
}
return len;
}
#else /* LWIP_HTTPD_FS_ASYNC_READ */
int
fs_read_custom(struct fs_file *file, char *buffer, int count)
{
struct fs_custom_data *data = (struct fs_custom_data *)file->pextension;
FILE *f;
int len;
int read_count = count;
LWIP_ASSERT("data not set", data != NULL);
#if LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ
read_count = LWIP_MIN(read_count, LWIP_HTTPD_EXAMPLE_CUSTOMFILES_LIMIT_READ);
#endif
f = data->f;
len = (int)fread(buffer, 1, read_count, f);
file->index += len;
/* Return FS_READ_EOF if all bytes have been read */
return len;
}
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
#endif /* LWIP_HTTPD_CUSTOM_FILES */
#endif /* LWIP_HTTPD_EXAMPLE_CUSTOMFILES */

View File

@@ -1,38 +0,0 @@
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#ifndef LWIP_HDR_HTTP_EXAMPLES_FS_EXAMPLE
#define LWIP_HDR_HTTP_EXAMPLES_FS_EXAMPLE
void fs_ex_init(const char *httpd_root_dir);
#endif /* LWIP_HDR_HTTP_EXAMPLES_FS_EXAMPLE */

View File

@@ -1,186 +0,0 @@
/**
* @file
* HTTPD custom file system example for runtime generated files
*
* This file demonstrates how to add support for generated files to httpd.
*/
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#include "lwip/opt.h"
#include "genfiles_example.h"
#include "lwip/apps/fs.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include <stdio.h>
#include <string.h>
/** define LWIP_HTTPD_EXAMPLE_GENERATEDFILES to 1 to enable this file system */
#ifndef LWIP_HTTPD_EXAMPLE_GENERATEDFILES
#define LWIP_HTTPD_EXAMPLE_GENERATEDFILES 0
#endif
#if LWIP_HTTPD_EXAMPLE_GENERATEDFILES
#if !LWIP_HTTPD_CUSTOM_FILES
#error This needs LWIP_HTTPD_CUSTOM_FILES
#endif
#if !LWIP_HTTPD_FILE_EXTENSION
#error This needs LWIP_HTTPD_FILE_EXTENSION
#endif
#if !LWIP_HTTPD_DYNAMIC_HEADERS
#error This needs LWIP_HTTPD_DYNAMIC_HEADERS
#endif
/* This is the page we send. It's not generated, as you see.
* Generating custom things instead of memcpy is left to your imagination :-)
*/
const char generated_html[] =
"<html>\n"
"<head><title>lwIP - A Lightweight TCP/IP Stack</title></head>\n"
" <body bgcolor=\"white\" text=\"black\">\n"
" <table width=\"100%\">\n"
" <tr valign=\"top\">\n"
" <td width=\"80\">\n"
" <a href=\"http://www.sics.se/\"><img src=\"/img/sics.gif\"\n"
" border=\"0\" alt=\"SICS logo\" title=\"SICS logo\"></a>\n"
" </td>\n"
" <td width=\"500\">\n"
" <h1>lwIP - A Lightweight TCP/IP Stack</h1>\n"
" <h2>Generated page</h2>\n"
" <p>This page might be generated in-memory at runtime</p>\n"
" </td>\n"
" <td>\n"
" &nbsp;\n"
" </td>\n"
" </tr>\n"
" </table>\n"
" </body>\n"
"</html>";
void
genfiles_ex_init(void)
{
/* nothing to do here yet */
}
int
fs_open_custom(struct fs_file *file, const char *name)
{
/* this example only provides one file */
if (!strcmp(name, "/generated.html")) {
/* initialize fs_file correctly */
memset(file, 0, sizeof(struct fs_file));
file->pextension = mem_malloc(sizeof(generated_html));
if (file->pextension != NULL) {
/* instead of doing memcpy, you would generate e.g. a JSON here */
memcpy(file->pextension, generated_html, sizeof(generated_html));
file->data = (const char *)file->pextension;
file->len = sizeof(generated_html) - 1; /* don't send the trailing 0 */
file->index = file->len;
/* allow persisteng connections */
file->flags = FS_FILE_FLAGS_HEADER_PERSISTENT;
return 1;
}
}
return 0;
}
void
fs_close_custom(struct fs_file *file)
{
if (file && file->pextension) {
mem_free(file->pextension);
file->pextension = NULL;
}
}
#if LWIP_HTTPD_FS_ASYNC_READ
u8_t
fs_canread_custom(struct fs_file *file)
{
LWIP_UNUSED_ARG(file);
/* This example does not use delayed/async reading */
return 1;
}
u8_t
fs_wait_read_custom(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg)
{
LWIP_ASSERT("not implemented in this example configuration", 0);
LWIP_UNUSED_ARG(file);
LWIP_UNUSED_ARG(callback_fn);
LWIP_UNUSED_ARG(callback_arg);
/* Return
- 1 if ready to read (at least one byte)
- 0 if reading should be delayed (call 'tcpip_callback(callback_fn, callback_arg)' when ready) */
return 1;
}
int
fs_read_async_custom(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg)
{
LWIP_ASSERT("not implemented in this example configuration", 0);
LWIP_UNUSED_ARG(file);
LWIP_UNUSED_ARG(buffer);
LWIP_UNUSED_ARG(count);
LWIP_UNUSED_ARG(callback_fn);
LWIP_UNUSED_ARG(callback_arg);
/* Return
- FS_READ_EOF if all bytes have been read
- FS_READ_DELAYED if reading is delayed (call 'tcpip_callback(callback_fn, callback_arg)' when done) */
/* all bytes read already */
return FS_READ_EOF;
}
#else /* LWIP_HTTPD_FS_ASYNC_READ */
int
fs_read_custom(struct fs_file *file, char *buffer, int count)
{
LWIP_ASSERT("not implemented in this example configuration", 0);
LWIP_UNUSED_ARG(file);
LWIP_UNUSED_ARG(buffer);
LWIP_UNUSED_ARG(count);
/* Return
- FS_READ_EOF if all bytes have been read
- FS_READ_DELAYED if reading is delayed (call 'tcpip_callback(callback_fn, callback_arg)' when done) */
/* all bytes read already */
return FS_READ_EOF;
}
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
#endif /* LWIP_HTTPD_EXAMPLE_GENERATEDFILES */

View File

@@ -1,38 +0,0 @@
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#ifndef LWIP_HDR_HTTP_EXAMPLES_GENFILES_EXAMPLE
#define LWIP_HDR_HTTP_EXAMPLES_GENFILES_EXAMPLE
void genfiles_ex_init(void);
#endif /* LWIP_HDR_HTTP_EXAMPLES_GENFILES_EXAMPLE */

View File

@@ -1,144 +0,0 @@
/**
* @file
* HTTPD https example
*
* This file demonstrates how to initialize httpd for https.
* To do this, it needs 2 files:
* - server certificate
* - server private key
*
* In addition to that, watch out for resource shortage. You'll need plenty of
* heap (start with MEM_SIZE >= 200 KByte or monitor its err counters) and be
* sure to at least set the following settings high enough (monitor
* lwip_stats for an idea of what's needed):
* - MEMP_NUM_TCP_PCB/MEMP_NUM_ALTCP_PCB
* - MEMP_NUM_TCPIP_MSG_INPKT
* - MEMP_NUM_TCP_SEG
*/
/*
* Copyright (c) 2017-2019 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#include "lwip/opt.h"
#include "https_example.h"
#include "lwip/altcp_tls.h"
#include "lwip/apps/httpd.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/** define LWIP_HTTPD_EXAMPLE_HTTPS to 1 to enable this file system */
#ifndef LWIP_HTTPD_EXAMPLE_HTTPS
#define LWIP_HTTPD_EXAMPLE_HTTPS 0
#endif
#if LWIP_HTTPD_EXAMPLE_HTTPS && LWIP_ALTCP_TLS
#ifndef LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE
#error "define LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE to the created server private key"
#endif
/* If the key file is password-protected, define LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS */
#ifdef LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS
#ifndef LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS_LEN
#define LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS_LEN strlen(LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS)
#endif
#else
#define LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS NULL
#define LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS_LEN 0
#endif
#ifndef LWIP_HTTPD_EXAMPLE_HTTPS_CERT_FILE
#error "define LWIP_HTTPD_EXAMPLE_HTTPS_CERT_FILE to the created server certificate"
#endif
static u8_t *read_file(const char *filename, size_t *file_size)
{
u8_t *buf;
long fsize;
FILE *f = fopen(filename, "rb");
if (!f) {
return NULL;
}
fseek(f, 0, SEEK_END);
fsize = ftell(f);
fseek(f, 0, SEEK_SET);
buf = (u8_t *)malloc(fsize + 1);
if (!buf) {
fclose(f);
return NULL;
}
fread(buf, 1, fsize, f);
fclose(f);
buf[fsize] = 0;
if (file_size) {
/* Note: the '+ 1' is required for mbedTLS to correctly parse the buffer */
*file_size = (size_t)(fsize + 1);
}
return buf;
}
/** This function loads a server certificate and private key as x509 from disk.
* For information how to create such files, see mbedTLS tutorial ("How to
* generate a self-signed certificate") or OpenSSL documentation ("How to
* generate a self-signed certificate and private key using OpenSSL"), e.g.
* 'openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt'
* Copy the resulting files and define the path to them
*/
void
https_ex_init(void)
{
struct altcp_tls_config *conf;
u8_t *privkey, *cert;
size_t privkey_size, cert_size;
privkey = read_file(LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE, &privkey_size);
LWIP_ASSERT("Failed to open https server private key", privkey != NULL);
cert = read_file(LWIP_HTTPD_EXAMPLE_HTTPS_CERT_FILE, &cert_size);
LWIP_ASSERT("Failed to open https server certificate", cert != NULL);
conf = altcp_tls_create_config_server_privkey_cert(privkey, privkey_size,
LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS, LWIP_HTTPD_EXAMPLE_HTTPS_KEY_FILE_PASS_LEN, cert, cert_size);
LWIP_ASSERT("Failed to create https server config", conf != NULL);
httpd_inits(conf);
/* secure erase should be done in production environment */
free(privkey);
free(cert);
}
#endif /* LWIP_HTTPD_EXAMPLE_HTTPS */

View File

@@ -1,38 +0,0 @@
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#ifndef LWIP_HDR_HTTP_EXAMPLES_HTTPS_EXAMPLE
#define LWIP_HDR_HTTP_EXAMPLES_HTTPS_EXAMPLE
void https_ex_init(void);
#endif /* LWIP_HDR_HTTP_EXAMPLES_HTTPS_EXAMPLE */

View File

@@ -1,167 +0,0 @@
/**
* @file
* HTTPD example for simple POST
*/
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#include "lwip/opt.h"
#include "lwip/apps/httpd.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include <stdio.h>
#include <string.h>
/** define LWIP_HTTPD_EXAMPLE_GENERATEDFILES to 1 to enable this file system */
#ifndef LWIP_HTTPD_EXAMPLE_SIMPLEPOST
#define LWIP_HTTPD_EXAMPLE_SIMPLEPOST 0
#endif
#if LWIP_HTTPD_EXAMPLE_SIMPLEPOST
#if !LWIP_HTTPD_SUPPORT_POST
#error This needs LWIP_HTTPD_SUPPORT_POST
#endif
#define USER_PASS_BUFSIZE 16
static void *current_connection;
static void *valid_connection;
static char last_user[USER_PASS_BUFSIZE];
err_t
httpd_post_begin(void *connection, const char *uri, const char *http_request,
u16_t http_request_len, int content_len, char *response_uri,
u16_t response_uri_len, u8_t *post_auto_wnd)
{
LWIP_UNUSED_ARG(connection);
LWIP_UNUSED_ARG(http_request);
LWIP_UNUSED_ARG(http_request_len);
LWIP_UNUSED_ARG(content_len);
LWIP_UNUSED_ARG(post_auto_wnd);
if (!memcmp(uri, "/login.cgi", 11)) {
if (current_connection != connection) {
current_connection = connection;
valid_connection = NULL;
/* default page is "login failed" */
snprintf(response_uri, response_uri_len, "/loginfail.html");
/* e.g. for large uploads to slow flash over a fast connection, you should
manually update the rx window. That way, a sender can only send a full
tcp window at a time. If this is required, set 'post_aut_wnd' to 0.
We do not need to throttle upload speed here, so: */
*post_auto_wnd = 1;
return ERR_OK;
}
}
return ERR_VAL;
}
err_t
httpd_post_receive_data(void *connection, struct pbuf *p)
{
err_t ret;
LWIP_ASSERT("NULL pbuf", p != NULL);
if (current_connection == connection) {
u16_t token_user = pbuf_memfind(p, "user=", 5, 0);
u16_t token_pass = pbuf_memfind(p, "pass=", 5, 0);
if ((token_user != 0xFFFF) && (token_pass != 0xFFFF)) {
u16_t value_user = token_user + 5;
u16_t value_pass = token_pass + 5;
u16_t len_user = 0;
u16_t len_pass = 0;
u16_t tmp;
/* find user len */
tmp = pbuf_memfind(p, "&", 1, value_user);
if (tmp != 0xFFFF) {
len_user = tmp - value_user;
} else {
len_user = p->tot_len - value_user;
}
/* find pass len */
tmp = pbuf_memfind(p, "&", 1, value_pass);
if (tmp != 0xFFFF) {
len_pass = tmp - value_pass;
} else {
len_pass = p->tot_len - value_pass;
}
if ((len_user > 0) && (len_user < USER_PASS_BUFSIZE) &&
(len_pass > 0) && (len_pass < USER_PASS_BUFSIZE)) {
/* provide contiguous storage if p is a chained pbuf */
char buf_user[USER_PASS_BUFSIZE];
char buf_pass[USER_PASS_BUFSIZE];
char *user = (char *)pbuf_get_contiguous(p, buf_user, sizeof(buf_user), len_user, value_user);
char *pass = (char *)pbuf_get_contiguous(p, buf_pass, sizeof(buf_pass), len_pass, value_pass);
if (user && pass) {
user[len_user] = 0;
pass[len_pass] = 0;
if (!strcmp(user, "lwip") && !strcmp(pass, "post")) {
/* user and password are correct, create a "session" */
valid_connection = connection;
memcpy(last_user, user, sizeof(last_user));
}
}
}
}
/* not returning ERR_OK aborts the connection, so return ERR_OK unless the
connection is unknown */
ret = ERR_OK;
} else {
ret = ERR_VAL;
}
/* this function must ALWAYS free the pbuf it is passed or it will leak memory */
pbuf_free(p);
return ret;
}
void
httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len)
{
/* default page is "login failed" */
snprintf(response_uri, response_uri_len, "/loginfail.html");
if (current_connection == connection) {
if (valid_connection == connection) {
/* login succeeded */
snprintf(response_uri, response_uri_len, "/session.html");
}
current_connection = NULL;
valid_connection = NULL;
}
}
#endif /* LWIP_HTTPD_EXAMPLE_SIMPLEPOST*/

View File

@@ -1,264 +0,0 @@
/**
* @file
* HTTPD simple SSI example
*
* This file demonstrates how to add support for SSI.
* It does this in a very simple way by providing the three tags 'HelloWorld'
* 'counter', and 'MultiPart'.
*
* This file also demonstrates how to integrate CGI with SSI.
*/
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#include "lwip/opt.h"
#include "ssi_example.h"
#include "lwip/apps/httpd.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include <stdio.h>
#include <string.h>
/** define LWIP_HTTPD_EXAMPLE_SSI_SIMPLE to 1 to enable this ssi example*/
#ifndef LWIP_HTTPD_EXAMPLE_SSI_SIMPLE
#define LWIP_HTTPD_EXAMPLE_SSI_SIMPLE 0
#endif
/** define LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION to 1 to show how to
* integrate CGI into SSI (LWIP_HTTPD_CGI_SSI) */
#ifndef LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION
#define LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION 0
#endif
#if LWIP_HTTPD_EXAMPLE_SSI_SIMPLE
#if LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION
#if !LWIP_HTTPD_FILE_STATE
#error LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION needs LWIP_HTTPD_FILE_STATE
#endif
#if !LWIP_HTTPD_CGI_SSI
#error LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION needs LWIP_HTTPD_CGI_SSI
#endif
#define MAX_CGI_LEN 16
#endif
const char * ssi_example_tags[] = {
"HellWorl",
"counter",
"MultPart"
#if LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION
,"CgiParam"
#endif
};
u16_t ssi_example_ssi_handler(
#if LWIP_HTTPD_SSI_RAW
const char* ssi_tag_name,
#else /* LWIP_HTTPD_SSI_RAW */
int iIndex,
#endif /* LWIP_HTTPD_SSI_RAW */
char *pcInsert, int iInsertLen
#if LWIP_HTTPD_SSI_MULTIPART
, u16_t current_tag_part, u16_t *next_tag_part
#endif /* LWIP_HTTPD_SSI_MULTIPART */
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
, void *connection_state
#endif /* LWIP_HTTPD_FILE_STATE */
)
{
size_t printed;
#if LWIP_HTTPD_SSI_RAW
/* a real application could use if(!strcmp) blocks here, but we want to keep
the differences between configurations small, so translate string to index here */
int iIndex;
for (iIndex = 0; iIndex < LWIP_ARRAYSIZE(ssi_example_tags); iIndex++) {
if(!strcmp(ssi_tag_name, ssi_example_tags[iIndex])) {
break;
}
}
#endif
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
LWIP_UNUSED_ARG(connection_state);
#endif
switch (iIndex) {
case 0: /* "HelloWorld" */
printed = snprintf(pcInsert, iInsertLen, "Hello World!");
break;
case 1: /* "counter" */
{
static int counter;
counter++;
printed = snprintf(pcInsert, iInsertLen, "%d", counter);
}
break;
case 2: /* "MultPart" */
#if LWIP_HTTPD_SSI_MULTIPART
switch (current_tag_part) {
case 0:
printed = snprintf(pcInsert, iInsertLen, "part0");
*next_tag_part = 1;
break;
case 1:
printed = snprintf(pcInsert, iInsertLen, "part1");
*next_tag_part = 2;
break;
case 2:
printed = snprintf(pcInsert, iInsertLen, "part2");
break;
default:
printed = snprintf(pcInsert, iInsertLen, "unhandled part: %d", (int)current_tag_part);
break;
}
#else
printed = snprintf(pcInsert, iInsertLen, "LWIP_HTTPD_SSI_MULTIPART disabled");
#endif
break;
#if LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION
case 3:
if (connection_state) {
char *params = (char *)connection_state;
if (*params) {
printed = snprintf(pcInsert, iInsertLen, "%s", (char *)params);
} else {
printed = snprintf(pcInsert, iInsertLen, "none");
}
} else {
printed = snprintf(pcInsert, iInsertLen, "NULL");
}
break;
#endif
default: /* unknown tag */
printed = 0;
break;
}
LWIP_ASSERT("sane length", printed <= 0xFFFF);
return (u16_t)printed;
}
void
ssi_ex_init(void)
{
int i;
for (i = 0; i < LWIP_ARRAYSIZE(ssi_example_tags); i++) {
LWIP_ASSERT("tag too long for LWIP_HTTPD_MAX_TAG_NAME_LEN",
strlen(ssi_example_tags[i]) <= LWIP_HTTPD_MAX_TAG_NAME_LEN);
}
http_set_ssi_handler(ssi_example_ssi_handler,
#if LWIP_HTTPD_SSI_RAW
NULL, 0
#else
ssi_example_tags, LWIP_ARRAYSIZE(ssi_example_tags)
#endif
);
}
#if LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION
void *
fs_state_init(struct fs_file *file, const char *name)
{
char *ret;
LWIP_UNUSED_ARG(file);
LWIP_UNUSED_ARG(name);
ret = (char *)mem_malloc(MAX_CGI_LEN);
if (ret) {
*ret = 0;
}
return ret;
}
void
fs_state_free(struct fs_file *file, void *state)
{
LWIP_UNUSED_ARG(file);
if (state != NULL) {
mem_free(state);
}
}
void
httpd_cgi_handler(struct fs_file *file, const char* uri, int iNumParams,
char **pcParam, char **pcValue
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
, void *connection_state
#endif /* LWIP_HTTPD_FILE_STATE */
)
{
LWIP_UNUSED_ARG(file);
LWIP_UNUSED_ARG(uri);
if (connection_state != NULL) {
char *start = (char *)connection_state;
char *end = start + MAX_CGI_LEN;
int i;
memset(start, 0, MAX_CGI_LEN);
/* print a string of the arguments: */
for (i = 0; i < iNumParams; i++) {
size_t len;
len = end - start;
if (len) {
size_t inlen = strlen(pcParam[i]);
size_t copylen = LWIP_MIN(inlen, len);
memcpy(start, pcParam[i], copylen);
start += copylen;
len -= copylen;
}
if (len) {
*start = '=';
start++;
len--;
}
if (len) {
size_t inlen = strlen(pcValue[i]);
size_t copylen = LWIP_MIN(inlen, len);
memcpy(start, pcValue[i], copylen);
start += copylen;
len -= copylen;
}
if (len) {
*start = ';';
len--;
}
/* ensure NULL termination */
end--;
*end = 0;
}
}
}
#endif /* LWIP_HTTPD_EXAMPLE_SSI_SIMPLE_CGI_INTEGRATION */
#endif /* LWIP_HTTPD_EXAMPLE_SSI_SIMPLE */

View File

@@ -1,38 +0,0 @@
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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: Simon Goldschmidt <goldsimon@gmx.de>
*
*/
#ifndef LWIP_HDR_HTTP_EXAMPLES_SSI_EXAMPLE
#define LWIP_HDR_HTTP_EXAMPLES_SSI_EXAMPLE
void ssi_ex_init(void);
#endif /* LWIP_HDR_HTTP_EXAMPLES_SSI_EXAMPLE */

View File

@@ -1,50 +0,0 @@
/*
* 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: Dirk Ziegelmeier <dziegel@gmx.de>
*
*/
#include "lwip/apps/lwiperf.h"
#include "lwiperf_example.h"
static void
lwiperf_report(void *arg, enum lwiperf_report_type report_type,
const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port,
u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec)
{
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(local_addr);
LWIP_UNUSED_ARG(local_port);
LWIP_PLATFORM_DIAG(("IPERF report: type=%d, remote: %s:%d, total bytes: %"U32_F", duration in ms: %"U32_F", kbits/s: %"U32_F"\n",
(int)report_type, ipaddr_ntoa(remote_addr), (int)remote_port, bytes_transferred, ms_duration, bandwidth_kbitpsec));
}
void
lwiperf_example_init(void)
{
lwiperf_start_tcp_server_default(lwiperf_report, NULL);
}

Some files were not shown because too many files have changed in this diff Show More