├── .github └── workflows │ └── build.yaml ├── .gitignore ├── Android.mk ├── Application.mk ├── License ├── Makefile ├── README.md ├── build.mk └── src ├── api ├── api_lib.c ├── api_msg.c ├── err.c ├── if_api.c ├── netbuf.c ├── netdb.c ├── netifapi.c ├── sockets.c └── tcpip.c ├── core ├── altcp.c ├── altcp_alloc.c ├── altcp_tcp.c ├── def.c ├── dns.c ├── inet_chksum.c ├── init.c ├── ip.c ├── ipv4 │ ├── acd.c │ ├── autoip.c │ ├── dhcp.c │ ├── etharp.c │ ├── icmp.c │ ├── igmp.c │ ├── ip4.c │ ├── ip4_addr.c │ └── ip4_frag.c ├── ipv6 │ ├── dhcp6.c │ ├── ethip6.c │ ├── icmp6.c │ ├── inet6.c │ ├── ip6.c │ ├── ip6_addr.c │ ├── ip6_frag.c │ ├── mld6.c │ └── nd6.c ├── mem.c ├── memp.c ├── netif.c ├── pbuf.c ├── raw.c ├── stats.c ├── sys.c ├── tcp.c ├── tcp_in.c ├── tcp_out.c ├── timeouts.c └── udp.c ├── include ├── compat │ ├── posix │ │ ├── arpa │ │ │ └── inet.h │ │ ├── net │ │ │ └── if.h │ │ ├── netdb.h │ │ └── sys │ │ │ └── socket.h │ └── stdc │ │ └── errno.h ├── lwip │ ├── acd.h │ ├── altcp.h │ ├── altcp_tcp.h │ ├── altcp_tls.h │ ├── api.h │ ├── arch.h │ ├── autoip.h │ ├── debug.h │ ├── def.h │ ├── dhcp.h │ ├── dhcp6.h │ ├── dns.h │ ├── err.h │ ├── errno.h │ ├── etharp.h │ ├── ethip6.h │ ├── icmp.h │ ├── icmp6.h │ ├── if_api.h │ ├── igmp.h │ ├── inet.h │ ├── inet_chksum.h │ ├── init.h │ ├── init.h.cmake.in │ ├── ip.h │ ├── ip4.h │ ├── ip4_addr.h │ ├── ip4_frag.h │ ├── ip6.h │ ├── ip6_addr.h │ ├── ip6_frag.h │ ├── ip6_zone.h │ ├── ip_addr.h │ ├── mem.h │ ├── memp.h │ ├── mld6.h │ ├── nd6.h │ ├── netbuf.h │ ├── netdb.h │ ├── netif.h │ ├── netifapi.h │ ├── opt.h │ ├── pbuf.h │ ├── priv │ │ ├── altcp_priv.h │ │ ├── api_msg.h │ │ ├── mem_priv.h │ │ ├── memp_priv.h │ │ ├── memp_std.h │ │ ├── nd6_priv.h │ │ ├── raw_priv.h │ │ ├── sockets_priv.h │ │ ├── tcp_priv.h │ │ └── tcpip_priv.h │ ├── prot │ │ ├── acd.h │ │ ├── autoip.h │ │ ├── dhcp.h │ │ ├── dhcp6.h │ │ ├── dns.h │ │ ├── etharp.h │ │ ├── ethernet.h │ │ ├── iana.h │ │ ├── icmp.h │ │ ├── icmp6.h │ │ ├── ieee.h │ │ ├── igmp.h │ │ ├── ip.h │ │ ├── ip4.h │ │ ├── ip6.h │ │ ├── mld6.h │ │ ├── nd6.h │ │ ├── tcp.h │ │ └── udp.h │ ├── raw.h │ ├── sio.h │ ├── snmp.h │ ├── sockets.h │ ├── stats.h │ ├── sys.h │ ├── tcp.h │ ├── tcpbase.h │ ├── tcpip.h │ ├── timeouts.h │ └── udp.h └── netif │ ├── bridgeif.h │ ├── bridgeif_opts.h │ ├── etharp.h │ ├── ethernet.h │ ├── ieee802154.h │ ├── lowpan6.h │ ├── lowpan6_ble.h │ ├── lowpan6_common.h │ ├── lowpan6_opts.h │ ├── ppp │ ├── ccp.h │ ├── chap-md5.h │ ├── chap-new.h │ ├── chap_ms.h │ ├── eap.h │ ├── ecp.h │ ├── eui64.h │ ├── fsm.h │ ├── ipcp.h │ ├── ipv6cp.h │ ├── lcp.h │ ├── magic.h │ ├── mppe.h │ ├── polarssl │ │ ├── arc4.h │ │ ├── des.h │ │ ├── md4.h │ │ ├── md5.h │ │ └── sha1.h │ ├── ppp.h │ ├── ppp_impl.h │ ├── ppp_opts.h │ ├── pppapi.h │ ├── pppcrypt.h │ ├── pppdebug.h │ ├── pppoe.h │ ├── pppol2tp.h │ ├── pppos.h │ ├── upap.h │ └── vj.h │ ├── slipif.h │ └── zepif.h ├── netif ├── bridgeif.c ├── bridgeif_fdb.c ├── ethernet.c ├── lowpan6.c ├── lowpan6_ble.c ├── lowpan6_common.c ├── ppp │ ├── auth.c │ ├── ccp.c │ ├── chap-md5.c │ ├── chap-new.c │ ├── chap_ms.c │ ├── demand.c │ ├── eap.c │ ├── ecp.c │ ├── eui64.c │ ├── fsm.c │ ├── ipcp.c │ ├── ipv6cp.c │ ├── lcp.c │ ├── magic.c │ ├── mppe.c │ ├── multilink.c │ ├── polarssl │ │ ├── arc4.c │ │ ├── des.c │ │ ├── md4.c │ │ ├── md5.c │ │ └── sha1.c │ ├── ppp.c │ ├── pppapi.c │ ├── pppcrypt.c │ ├── pppoe.c │ ├── pppol2tp.c │ ├── pppos.c │ ├── upap.c │ ├── utils.c │ └── vj.c ├── slipif.c └── zepif.c └── ports ├── include ├── arch │ ├── bpstruct.h │ ├── cc.h │ ├── epstruct.h │ ├── perf.h │ └── sys_arch.h ├── lwipopts.h └── netif │ ├── fifo.h │ ├── list.h │ ├── pcapif.h │ ├── sio.h │ └── tapif.h ├── lib └── mem.c ├── unix ├── include │ ├── cc.h │ ├── netif │ │ ├── fifo.h │ │ ├── list.h │ │ ├── pcapif.h │ │ ├── sio.h │ │ └── tapif.h │ ├── perf.h │ └── sys_arch.h ├── lib │ ├── perf.c │ └── sys_arch.c └── netif │ ├── fifo.c │ ├── list.c │ ├── pcapif.c │ ├── sio.c │ └── tapif.c └── win32 ├── include ├── bpstruct.h ├── cc.h ├── epstruct.h ├── perf.h └── sys_arch.h ├── lib └── sys_arch.c └── netif └── sio.c /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | jobs: 11 | linux: 12 | name: Linux 13 | runs-on: ubuntu-22.04 14 | strategy: 15 | matrix: 16 | include: 17 | - name: arm64 18 | tool: aarch64-unknown-linux-musl 19 | - name: arm32 20 | tool: arm-unknown-linux-musleabi 21 | - name: arm32hf 22 | tool: arm-unknown-linux-musleabihf 23 | - name: arm32v7 24 | tool: armv7-unknown-linux-musleabi 25 | - name: arm32v7hf 26 | tool: armv7-unknown-linux-musleabihf 27 | - name: i586 28 | tool: i586-unknown-linux-musl 29 | - name: i686 30 | tool: i686-unknown-linux-musl 31 | - name: loong64 32 | tool: loongarch64-unknown-linux-musl 33 | - name: mips64el 34 | tool: mips64el-unknown-linux-musl 35 | - name: mips64 36 | tool: mips64-unknown-linux-musl 37 | - name: mips32el 38 | tool: mipsel-unknown-linux-musl 39 | - name: mips32elsf 40 | tool: mipsel-unknown-linux-muslsf 41 | - name: mips32 42 | tool: mips-unknown-linux-musl 43 | - name: mips32sf 44 | tool: mips-unknown-linux-muslsf 45 | - name: riscv32 46 | tool: riscv32-unknown-linux-musl 47 | - name: riscv64 48 | tool: riscv64-unknown-linux-musl 49 | - name: x86_64 50 | tool: x86_64-unknown-linux-musl 51 | steps: 52 | - name: Checkout 53 | uses: actions/checkout@v4 54 | with: 55 | fetch-depth: 1 56 | submodules: true 57 | - name: Build ${{ matrix.name }} 58 | run: | 59 | sudo mkdir -p /opt/x-tools 60 | wget https://github.com/musl-cross/musl-cross/releases/download/20250206/${{ matrix.tool }}.tar.xz 61 | sudo tar xf ${{ matrix.tool }}.tar.xz -C /opt/x-tools 62 | make CROSS_PREFIX=/opt/x-tools/${{ matrix.tool }}/bin/${{ matrix.tool }}- CFLAGS=${{ matrix.env.CFLAGS }} ENABLE_STATIC=1 -j`nproc` 63 | 64 | macos: 65 | name: macOS 66 | runs-on: macos-14 67 | steps: 68 | - name: Checkout 69 | uses: actions/checkout@v4 70 | with: 71 | fetch-depth: 1 72 | submodules: true 73 | - name: Build 74 | run: | 75 | make 76 | 77 | android: 78 | name: Android 79 | runs-on: ubuntu-22.04 80 | steps: 81 | - name: Checkout 82 | uses: actions/checkout@v4 83 | with: 84 | fetch-depth: 1 85 | submodules: true 86 | - name: Prepare 87 | run: | 88 | wget https://dl.google.com/android/repository/android-ndk-r27b-linux.zip 89 | unzip android-ndk-r27b-linux.zip 90 | ln -sf . jni 91 | - name: Build 92 | run: | 93 | ./android-ndk-r27b/ndk-build 94 | 95 | llvm: 96 | name: LLVM 97 | runs-on: ubuntu-22.04 98 | steps: 99 | - name: Checkout 100 | uses: actions/checkout@v4 101 | with: 102 | fetch-depth: 1 103 | submodules: true 104 | - name: Prepare 105 | run: | 106 | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - 107 | sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main' 108 | sudo apt install -y clang 109 | - name: Build 110 | run: | 111 | make CC=clang ENABLE_STATIC=1 -j`nproc` 112 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | build 3 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | SRCDIR := $(LOCAL_PATH)/src 18 | 19 | include $(CLEAR_VARS) 20 | include $(LOCAL_PATH)/build.mk 21 | LOCAL_MODULE := liblwip 22 | LOCAL_SRC_FILES := $(patsubst $(SRCDIR)/%,src/%,$(SRCFILES)) 23 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/src/include $(LOCAL_PATH)/src/ports/include 24 | LOCAL_CFLAGS += -DFD_SET_DEFINED -DSOCKLEN_T_DEFINED 25 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 26 | LOCAL_CFLAGS += -mfpu=neon 27 | endif 28 | include $(BUILD_STATIC_LIBRARY) 29 | -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | APP_OPTIM := release 17 | APP_PLATFORM := android-21 18 | APP_ABI := armeabi-v7a arm64-v8a 19 | APP_CFLAGS := -O3 20 | NDK_TOOLCHAIN_VERSION := clang 21 | -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 3. The name of the author may not be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 18 | SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 20 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 24 | OF SUCH DAMAGE. 25 | 26 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for lwip 2 | 3 | PROJECT=lwip 4 | 5 | CROSS_PREFIX := 6 | PP=$(CROSS_PREFIX)cpp 7 | CC=$(CROSS_PREFIX)gcc 8 | LD=$(CROSS_PREFIX)ld 9 | AR=$(CROSS_PREFIX)ar 10 | CCFLAGS=-O3 -pipe $(CFLAGS) 11 | LDFLAGS=$(LFLAGS) 12 | 13 | SRCDIR=src 14 | BINDIR=bin 15 | BUILDDIR=build 16 | 17 | STATIC_TARGET=$(BINDIR)/lib$(PROJECT).a 18 | SHARED_TARGET=$(BINDIR)/lib$(PROJECT).so 19 | 20 | $(SHARED_TARGET) : CCFLAGS+=-fPIC 21 | $(SHARED_TARGET) : LDFLAGS+=-shared -pthread 22 | 23 | -include build.mk 24 | CCFLAGS+=-Isrc/include -Isrc/ports/include 25 | 26 | CCSRCS=$(filter %.c,$(SRCFILES)) 27 | ASSRCS=$(filter %.S,$(SRCFILES)) 28 | LDOBJS=$(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(CCSRCS)) \ 29 | $(patsubst $(SRCDIR)/%.S,$(BUILDDIR)/%.o,$(ASSRCS)) 30 | DEPEND=$(LDOBJS:.o=.dep) 31 | 32 | BUILDMSG="\e[1;31mBUILD\e[0m %s\n" 33 | LINKMSG="\e[1;34mLINK\e[0m \e[1;32m%s\e[0m\n" 34 | CLEANMSG="\e[1;34mCLEAN\e[0m %s\n" 35 | TESTMSG="\e[1;34mTEST\e[0m \e[1;32m%s\e[0m\n" 36 | 37 | ENABLE_DEBUG := 38 | ifeq ($(ENABLE_DEBUG),1) 39 | CCFLAGS+=-g -O0 -DENABLE_DEBUG 40 | endif 41 | 42 | V:= 43 | ECHO_PREFIX:=@ 44 | ifeq ($(V),1) 45 | undefine ECHO_PREFIX 46 | endif 47 | 48 | .PHONY: static shared clean 49 | 50 | static : $(STATIC_TARGET) 51 | 52 | shared : $(SHARED_TARGET) 53 | 54 | clean : 55 | $(ECHO_PREFIX) $(RM) -rf $(BINDIR) $(BUILDDIR) 56 | @printf $(CLEANMSG) $(PROJECT) 57 | 58 | $(STATIC_TARGET) : $(LDOBJS) 59 | $(ECHO_PREFIX) mkdir -p $(dir $@) 60 | $(ECHO_PREFIX) $(AR) csq $@ $^ 61 | @printf $(LINKMSG) $@ 62 | 63 | $(SHARED_TARGET) : $(LDOBJS) 64 | $(ECHO_PREFIX) mkdir -p $(dir $@) 65 | $(ECHO_PREFIX) $(CC) -o $@ $^ $(LDFLAGS) 66 | @printf $(LINKMSG) $@ 67 | 68 | $(BUILDDIR)/%.dep : $(SRCDIR)/%.c 69 | $(ECHO_PREFIX) mkdir -p $(dir $@) 70 | $(ECHO_PREFIX) $(PP) $(CCFLAGS) -MM -MT$(@:.dep=.o) -MF$@ $< 2>/dev/null 71 | 72 | $(BUILDDIR)/%.dep : $(SRCDIR)/%.S 73 | $(ECHO_PREFIX) mkdir -p $(dir $@) 74 | $(ECHO_PREFIX) $(PP) $(CCFLAGS) -MM -MT$(@:.dep=.o) -MF$@ $< 2>/dev/null 75 | 76 | $(BUILDDIR)/%.o : $(SRCDIR)/%.c 77 | $(ECHO_PREFIX) mkdir -p $(dir $@) 78 | $(ECHO_PREFIX) $(CC) $(CCFLAGS) -c -o $@ $< 79 | @printf $(BUILDMSG) $< 80 | 81 | $(BUILDDIR)/%.o : $(SRCDIR)/%.S 82 | $(ECHO_PREFIX) mkdir -p $(dir $@) 83 | $(ECHO_PREFIX) $(CC) $(CCFLAGS) -c -o $@ $< 84 | @printf $(BUILDMSG) $< 85 | 86 | ifneq ($(MAKECMDGOALS),clean) 87 | -include $(DEPEND) 88 | endif 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LwIP 2 | 3 | [![status](https://github.com/heiher/lwip/actions/workflows/build.yaml/badge.svg?branch=master&event=push)](https://github.com/heiher/lwip) 4 | 5 | This is a branch of liblwip with a simple build system. 6 | 7 | ## Features 8 | 9 | * UDP: Allow receiving packets are not destined to localhost. 10 | * TCP: Allow accepting connections are not destined to localhost. 11 | 12 | ## Examples 13 | 14 | ### TCP 15 | 16 | ```c 17 | static void 18 | gateway_init(void) 19 | { 20 | // Init netif 21 | netif_set_up (&netif); 22 | netif_set_link_up (&netif); 23 | netif_set_default (&netif); 24 | 25 | // Allow to pretend TCP on this netif 26 | netif_set_flags (&netif, NETIF_FLAG_PRETEND_TCP); 27 | 28 | tcp = tcp_new_ip_type (IPADDR_TYPE_ANY); 29 | 30 | // Bind TCP to netif first 31 | tcp_bind_netif (tcp, &netif); 32 | 33 | // Bind to accept incoming connections to other hosts 34 | tcp_bind (tcp, NULL, 0); 35 | 36 | tcp_listen (tcp); 37 | tcp_accept (tcp, tcp_accept_handler); 38 | } 39 | 40 | static err_t 41 | tcp_accept_handler (void *arg, struct tcp_pcb *pcb, err_t err) 42 | { 43 | // Accept new TCP connection 44 | // @pcb->local_ip: The real destination address 45 | // @pcb->local_port: The real destination port 46 | // @pcb->remote_ip: The real source address 47 | // @pcb->remote_port: The real source port 48 | } 49 | ``` 50 | 51 | ### UDP 52 | 53 | ```c 54 | static void 55 | gateway_init(void) 56 | { 57 | // Init netif 58 | netif_set_up (&netif); 59 | netif_set_link_up (&netif); 60 | netif_set_default (&netif); 61 | 62 | // Allow to pretend UDP on this netif 63 | netif_set_flags (&netif, NETIF_FLAG_PRETEND_UDP); 64 | 65 | udp = udp_new_ip_type (IPADDR_TYPE_ANY); 66 | 67 | // Bind TCP to netif first 68 | udp_bind_netif (udp, &netif); 69 | 70 | // Bind to receive packets to other hosts 71 | udp_bind (udp, NULL, 0); 72 | 73 | udp_recv (udp, udp_accept_handler, NULL); 74 | } 75 | 76 | static void 77 | udp_accept_handler (void *arg, struct udp_pcb *pcb, struct pbuf *p, 78 | const ip_addr_t *addr, u16_t port) 79 | { 80 | // Similar to TCP accept, receive packets on new UDP PCB. 81 | // @pcb: An new UDP PCB for sending and receiving. 82 | // @p: Unused 83 | // @addr: Unused 84 | // @port: Unused 85 | udp_recv (pcb, udp_recv_handler, NULL); 86 | } 87 | 88 | static void 89 | udp_recv_handler (void *arg, struct udp_pcb *pcb, struct pbuf *p, 90 | const ip_addr_t *addr, u16_t port) 91 | { 92 | // Receive UDP packets 93 | 94 | // @pcb->local_ip: The real destination address 95 | // @pcb->local_port: The real destination port 96 | // @pcb->remote_ip: The real source address 97 | // @pcb->remote_port: The real source port 98 | // @addr: Unused 99 | // @port: Unused 100 | 101 | // Send with source address 102 | udp_sendfrom (pcb, p, real_src_ip, real_src_port); 103 | pbuf_free (p); 104 | } 105 | ``` 106 | 107 | ## How to Build 108 | 109 | **Unix**: 110 | ```bash 111 | git clone https://gitlab.com/hev/lwip 112 | cd lwip 113 | make 114 | ``` 115 | 116 | **Android**: 117 | ```bash 118 | mkdir lwip 119 | cd lwip 120 | git clone https://gitlab.com/hev/lwip jni 121 | ndk-build 122 | ``` 123 | 124 | **Windows**: 125 | ```bash 126 | git clone https://gitlab.com/hev/lwip 127 | cd lwip 128 | make CROSS_PREFIX=x86_64-w64-mingw32- 129 | ``` 130 | 131 | ## Upstream 132 | https://savannah.nongnu.org/projects/lwip 133 | 134 | [PROJECT_URL]: https://gitlab.com/hev/lwip/commits/master 135 | [PIPELINE_STATUS]: https://gitlab.com/hev/lwip/badges/master/pipeline.svg 136 | -------------------------------------------------------------------------------- /build.mk: -------------------------------------------------------------------------------- 1 | # Build 2 | 3 | rwildcard=$(foreach d,$(wildcard $1*), \ 4 | $(call rwildcard,$d/,$2) \ 5 | $(filter $(subst *,%,$2),$d)) 6 | 7 | SRCFILES=$(call rwildcard,$(SRCDIR)/,*.c *.S) 8 | -------------------------------------------------------------------------------- /src/api/if_api.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Interface Identification APIs from: 4 | * RFC 3493: Basic Socket Interface Extensions for IPv6 5 | * Section 4: Interface Identification 6 | * 7 | * @defgroup if_api Interface Identification API 8 | * @ingroup socket 9 | */ 10 | 11 | /* 12 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. The name of the author may not be used to endorse or promote products 24 | * derived from this software without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 29 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 30 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 31 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 34 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 35 | * OF SUCH DAMAGE. 36 | * 37 | * This file is part of the lwIP TCP/IP stack. 38 | * 39 | * Author: Joel Cunningham 40 | * 41 | */ 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_SOCKET 45 | 46 | #include "lwip/errno.h" 47 | #include "lwip/if_api.h" 48 | #include "lwip/netifapi.h" 49 | #include "lwip/priv/sockets_priv.h" 50 | 51 | /** 52 | * @ingroup if_api 53 | * Maps an interface index to its corresponding name. 54 | * @param ifindex interface index 55 | * @param ifname shall point to a buffer of at least {IF_NAMESIZE} bytes 56 | * @return If ifindex is an interface index, then the function shall return the 57 | * value supplied in ifname, which points to a buffer now containing the interface name. 58 | * Otherwise, the function shall return a NULL pointer. 59 | */ 60 | char * 61 | lwip_if_indextoname(unsigned int ifindex, char *ifname) 62 | { 63 | #if LWIP_NETIF_API 64 | if (ifindex <= 0xff) { 65 | err_t err = netifapi_netif_index_to_name((u8_t)ifindex, ifname); 66 | if (!err && ifname[0] != '\0') { 67 | return ifname; 68 | } 69 | } 70 | #else /* LWIP_NETIF_API */ 71 | LWIP_UNUSED_ARG(ifindex); 72 | LWIP_UNUSED_ARG(ifname); 73 | #endif /* LWIP_NETIF_API */ 74 | set_errno(ENXIO); 75 | return NULL; 76 | } 77 | 78 | /** 79 | * @ingroup if_api 80 | * Returns the interface index corresponding to name ifname. 81 | * @param ifname Interface name 82 | * @return The corresponding index if ifname is the name of an interface; 83 | * otherwise, zero. 84 | */ 85 | unsigned int 86 | lwip_if_nametoindex(const char *ifname) 87 | { 88 | #if LWIP_NETIF_API 89 | err_t err; 90 | u8_t idx; 91 | 92 | err = netifapi_netif_name_to_index(ifname, &idx); 93 | if (!err) { 94 | return idx; 95 | } 96 | #else /* LWIP_NETIF_API */ 97 | LWIP_UNUSED_ARG(ifname); 98 | #endif /* LWIP_NETIF_API */ 99 | return 0; /* invalid index */ 100 | } 101 | 102 | #endif /* LWIP_SOCKET */ 103 | -------------------------------------------------------------------------------- /src/core/altcp_alloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP connection API (to be used from TCPIP thread)
4 | * This interface mimics the tcp callback API to the application while preventing 5 | * direct linking (much like virtual functions). 6 | * This way, an application can make use of other application layer protocols 7 | * on top of TCP without knowing the details (e.g. TLS, proxy connection). 8 | * 9 | * This file contains allocation implementation that combine several layers. 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2017 Simon Goldschmidt 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. The name of the author may not be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 30 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 32 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 35 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 36 | * OF SUCH DAMAGE. 37 | * 38 | * This file is part of the lwIP TCP/IP stack. 39 | * 40 | * Author: Simon Goldschmidt 41 | * 42 | */ 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/altcp.h" 49 | #include "lwip/altcp_tcp.h" 50 | #include "lwip/altcp_tls.h" 51 | #include "lwip/priv/altcp_priv.h" 52 | #include "lwip/mem.h" 53 | 54 | #include 55 | 56 | #if LWIP_ALTCP_TLS 57 | 58 | /** This standard allocator function creates an altcp pcb for 59 | * TLS over TCP */ 60 | struct altcp_pcb * 61 | altcp_tls_new(struct altcp_tls_config *config, u8_t ip_type) 62 | { 63 | struct altcp_pcb *inner_conn, *ret; 64 | LWIP_UNUSED_ARG(ip_type); 65 | 66 | inner_conn = altcp_tcp_new_ip_type(ip_type); 67 | if (inner_conn == NULL) { 68 | return NULL; 69 | } 70 | ret = altcp_tls_wrap(config, inner_conn); 71 | if (ret == NULL) { 72 | altcp_close(inner_conn); 73 | } 74 | return ret; 75 | } 76 | 77 | /** This standard allocator function creates an altcp pcb for 78 | * TLS over TCP */ 79 | struct altcp_pcb * 80 | altcp_tls_alloc(void *arg, u8_t ip_type) 81 | { 82 | return altcp_tls_new((struct altcp_tls_config *)arg, ip_type); 83 | } 84 | 85 | #endif /* LWIP_ALTCP_TLS */ 86 | 87 | #endif /* LWIP_ALTCP */ 88 | -------------------------------------------------------------------------------- /src/core/ipv6/inet6.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * INET v6 addresses. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_IPV6 && LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/def.h" 47 | #include "lwip/inet.h" 48 | 49 | /** This variable is initialized by the system to contain the wildcard IPv6 address. 50 | */ 51 | const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; 52 | 53 | #endif /* LWIP_IPV6 */ 54 | -------------------------------------------------------------------------------- /src/include/compat/posix/arpa/inet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /src/include/compat/posix/net/if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/if_api.h. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | */ 35 | 36 | #include "lwip/if_api.h" 37 | -------------------------------------------------------------------------------- /src/include/compat/posix/netdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/netdb.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/netdb.h" 34 | -------------------------------------------------------------------------------- /src/include/compat/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /src/include/compat/stdc/errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix/stdc wrapper for lwip/errno.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/errno.h" 34 | -------------------------------------------------------------------------------- /src/include/lwip/altcp_tcp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Application layered TCP connection API (to be used from TCPIP thread)
4 | * This interface mimics the tcp callback API to the application while preventing 5 | * direct linking (much like virtual functions). 6 | * This way, an application can make use of other application layer protocols 7 | * on top of TCP without knowing the details (e.g. TLS, proxy connection). 8 | * 9 | * This file contains the base implementation calling into tcp. 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2017 Simon Goldschmidt 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. The name of the author may not be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 30 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 32 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 35 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 36 | * OF SUCH DAMAGE. 37 | * 38 | * This file is part of the lwIP TCP/IP stack. 39 | * 40 | * Author: Simon Goldschmidt 41 | * 42 | */ 43 | #ifndef LWIP_HDR_ALTCP_TCP_H 44 | #define LWIP_HDR_ALTCP_TCP_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */ 49 | 50 | #include "lwip/altcp.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | struct altcp_pcb *altcp_tcp_new_ip_type(u8_t ip_type); 57 | 58 | #define altcp_tcp_new() altcp_tcp_new_ip_type(IPADDR_TYPE_V4) 59 | #define altcp_tcp_new_ip6() altcp_tcp_new_ip_type(IPADDR_TYPE_V6) 60 | 61 | struct altcp_pcb *altcp_tcp_alloc(void *arg, u8_t ip_type); 62 | 63 | struct tcp_pcb; 64 | struct altcp_pcb *altcp_tcp_wrap(struct tcp_pcb *tpcb); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* LWIP_ALTCP */ 71 | 72 | #endif /* LWIP_HDR_ALTCP_TCP_H */ 73 | -------------------------------------------------------------------------------- /src/include/lwip/autoip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * AutoIP Automatic LinkLocal IP Configuration 5 | */ 6 | 7 | /* 8 | * 9 | * Copyright (c) 2007 Dominik Spies 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * Author: Dominik Spies 35 | * 36 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 37 | * with RFC 3927. 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_AUTOIP_H 42 | #define LWIP_HDR_AUTOIP_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/netif.h" 49 | /* #include "lwip/udp.h" */ 50 | #include "lwip/etharp.h" 51 | #include "lwip/acd.h" 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** AutoIP state information per netif */ 58 | struct autoip 59 | { 60 | /** the currently selected, probed, announced or used LL IP-Address */ 61 | ip4_addr_t llipaddr; 62 | /** current AutoIP state machine state */ 63 | u8_t state; 64 | /** total number of probed/used Link Local IP-Addresses */ 65 | u8_t tried_llipaddr; 66 | /** acd struct */ 67 | struct acd acd; 68 | }; 69 | 70 | 71 | void autoip_set_struct(struct netif *netif, struct autoip *autoip); 72 | void autoip_remove_struct(struct netif *netif); 73 | err_t autoip_start(struct netif *netif); 74 | err_t autoip_stop(struct netif *netif); 75 | void autoip_network_changed_link_up(struct netif *netif); 76 | void autoip_network_changed_link_down(struct netif *netif); 77 | u8_t autoip_supplied_address(struct netif *netif); 78 | 79 | /* for lwIP internal use by ip4.c */ 80 | u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr); 81 | 82 | #define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP)) 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* LWIP_IPV4 && LWIP_AUTOIP */ 89 | 90 | #endif /* LWIP_HDR_AUTOIP_H */ 91 | -------------------------------------------------------------------------------- /src/include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Error codes 4 | */ 5 | /* 6 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 23 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 25 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 29 | * OF SUCH DAMAGE. 30 | * 31 | * This file is part of the lwIP TCP/IP stack. 32 | * 33 | * Author: Adam Dunkels 34 | * 35 | */ 36 | #ifndef LWIP_HDR_ERR_H 37 | #define LWIP_HDR_ERR_H 38 | 39 | #include "lwip/opt.h" 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** 47 | * @defgroup infrastructure_errors Error codes 48 | * @ingroup infrastructure 49 | * @{ 50 | */ 51 | 52 | /** Definitions for error constants. */ 53 | typedef enum { 54 | /** No error, everything OK. */ 55 | ERR_OK = 0, 56 | /** Out of memory error. */ 57 | ERR_MEM = -1, 58 | /** Buffer error. */ 59 | ERR_BUF = -2, 60 | /** Timeout. */ 61 | ERR_TIMEOUT = -3, 62 | /** Routing problem. */ 63 | ERR_RTE = -4, 64 | /** Operation in progress */ 65 | ERR_INPROGRESS = -5, 66 | /** Illegal value. */ 67 | ERR_VAL = -6, 68 | /** Operation would block. */ 69 | ERR_WOULDBLOCK = -7, 70 | /** Address in use. */ 71 | ERR_USE = -8, 72 | /** Already connecting. */ 73 | ERR_ALREADY = -9, 74 | /** Conn already established.*/ 75 | ERR_ISCONN = -10, 76 | /** Not connected. */ 77 | ERR_CONN = -11, 78 | /** Low-level netif error */ 79 | ERR_IF = -12, 80 | 81 | /** Connection aborted. */ 82 | ERR_ABRT = -13, 83 | /** Connection reset. */ 84 | ERR_RST = -14, 85 | /** Connection closed. */ 86 | ERR_CLSD = -15, 87 | /** Illegal argument. */ 88 | ERR_ARG = -16 89 | } err_enum_t; 90 | 91 | /** Define LWIP_ERR_T in cc.h if you want to use 92 | * a different type for your platform (must be signed). */ 93 | #ifdef LWIP_ERR_T 94 | typedef LWIP_ERR_T err_t; 95 | #else /* LWIP_ERR_T */ 96 | typedef s8_t err_t; 97 | #endif /* LWIP_ERR_T*/ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | #ifdef LWIP_DEBUG 104 | extern const char *lwip_strerr(err_t err); 105 | #else 106 | #define lwip_strerr(x) "" 107 | #endif /* LWIP_DEBUG */ 108 | 109 | #if !NO_SYS 110 | int err_to_errno(err_t err); 111 | #endif /* !NO_SYS */ 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif /* LWIP_HDR_ERR_H */ 118 | -------------------------------------------------------------------------------- /src/include/lwip/ethip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Ethernet output for IPv6. Uses ND tables for link-layer addressing. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_ETHIP6_H 43 | #define LWIP_HDR_ETHIP6_H 44 | 45 | #include "lwip/opt.h" 46 | 47 | #if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip6.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | 60 | err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_IPV6 && LWIP_ETHERNET */ 67 | 68 | #endif /* LWIP_HDR_ETHIP6_H */ 69 | -------------------------------------------------------------------------------- /src/include/lwip/icmp6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 version of ICMP, as per RFC 4443. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | #ifndef LWIP_HDR_ICMP6_H 42 | #define LWIP_HDR_ICMP6_H 43 | 44 | #include "lwip/opt.h" 45 | #include "lwip/pbuf.h" 46 | #include "lwip/ip6_addr.h" 47 | #include "lwip/netif.h" 48 | #include "lwip/prot/icmp6.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 55 | 56 | void icmp6_input(struct pbuf *p, struct netif *inp); 57 | void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c); 58 | void icmp6_packet_too_big(struct pbuf *p, u32_t mtu); 59 | void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c); 60 | void icmp6_time_exceeded_with_addrs(struct pbuf *p, enum icmp6_te_code c, 61 | const ip6_addr_t *src_addr, const ip6_addr_t *dest_addr); 62 | void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, const void *pointer); 63 | 64 | #endif /* LWIP_ICMP6 && LWIP_IPV6 */ 65 | 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | 72 | #endif /* LWIP_HDR_ICMP6_H */ 73 | -------------------------------------------------------------------------------- /src/include/lwip/if_api.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Interface Identification APIs from: 4 | * RFC 3493: Basic Socket Interface Extensions for IPv6 5 | * Section 4: Interface Identification 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Joel Cunningham 37 | * 38 | */ 39 | #ifndef LWIP_HDR_IF_H 40 | #define LWIP_HDR_IF_H 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/netif.h" 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #ifndef IF_NAMESIZE 53 | #define IF_NAMESIZE NETIF_NAMESIZE 54 | #endif 55 | 56 | char * lwip_if_indextoname(unsigned int ifindex, char *ifname); 57 | unsigned int lwip_if_nametoindex(const char *ifname); 58 | 59 | #if LWIP_COMPAT_SOCKETS 60 | #define if_indextoname(ifindex, ifname) lwip_if_indextoname(ifindex,ifname) 61 | #define if_nametoindex(ifname) lwip_if_nametoindex(ifname) 62 | #endif /* LWIP_COMPAT_SOCKETS */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* LWIP_SOCKET */ 69 | 70 | #endif /* LWIP_HDR_IF_H */ 71 | -------------------------------------------------------------------------------- /src/include/lwip/init.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP initialization API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_INIT_H 38 | #define LWIP_HDR_INIT_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** 47 | * @defgroup lwip_version Version 48 | * @ingroup lwip 49 | * @{ 50 | */ 51 | 52 | /** X.x.x: Major version of the stack */ 53 | #define LWIP_VERSION_MAJOR 2 54 | /** x.X.x: Minor version of the stack */ 55 | #define LWIP_VERSION_MINOR 2 56 | /** x.x.X: Revision of the stack */ 57 | #define LWIP_VERSION_REVISION 1 58 | /** For release candidates, this is set to 1..254 59 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 60 | * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 61 | #define LWIP_VERSION_RC LWIP_RC_RELEASE 62 | 63 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 64 | #define LWIP_RC_RELEASE 255 65 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions */ 66 | #define LWIP_RC_DEVELOPMENT 0 67 | 68 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 69 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 70 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 71 | 72 | /* Some helper defines to get a version string */ 73 | #define LWIP_VERSTR2(x) #x 74 | #define LWIP_VERSTR(x) LWIP_VERSTR2(x) 75 | #if LWIP_VERSION_IS_RELEASE 76 | #define LWIP_VERSION_STRING_SUFFIX "" 77 | #elif LWIP_VERSION_IS_DEVELOPMENT 78 | #define LWIP_VERSION_STRING_SUFFIX "d" 79 | #else 80 | #define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) 81 | #endif 82 | 83 | /** Provides the version of the stack */ 84 | #define LWIP_VERSION ((LWIP_VERSION_MAJOR) << 24 | (LWIP_VERSION_MINOR) << 16 | \ 85 | (LWIP_VERSION_REVISION) << 8 | (LWIP_VERSION_RC)) 86 | /** Provides the version of the stack as string */ 87 | #define LWIP_VERSION_STRING LWIP_VERSTR(LWIP_VERSION_MAJOR) "." LWIP_VERSTR(LWIP_VERSION_MINOR) "." LWIP_VERSTR(LWIP_VERSION_REVISION) LWIP_VERSION_STRING_SUFFIX 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /* Modules initialization */ 94 | void lwip_init(void); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* LWIP_HDR_INIT_H */ 101 | -------------------------------------------------------------------------------- /src/include/lwip/ip4_frag.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IP fragmentation/reassembly 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Jani Monoses 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_IP4_FRAG_H 39 | #define LWIP_HDR_IP4_FRAG_H 40 | 41 | #include "lwip/opt.h" 42 | #include "lwip/err.h" 43 | #include "lwip/pbuf.h" 44 | #include "lwip/netif.h" 45 | #include "lwip/ip_addr.h" 46 | #include "lwip/ip.h" 47 | 48 | #if LWIP_IPV4 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if IP_REASSEMBLY 55 | /* The IP reassembly timer interval in milliseconds. */ 56 | #define IP_TMR_INTERVAL 1000 57 | 58 | /** IP reassembly helper struct. 59 | * This is exported because memp needs to know the size. 60 | */ 61 | struct ip_reassdata { 62 | struct ip_reassdata *next; 63 | struct pbuf *p; 64 | struct ip_hdr iphdr; 65 | u16_t datagram_len; 66 | u8_t flags; 67 | u8_t timer; 68 | }; 69 | 70 | void ip_reass_init(void); 71 | void ip_reass_tmr(void); 72 | struct pbuf * ip4_reass(struct pbuf *p); 73 | #endif /* IP_REASSEMBLY */ 74 | 75 | #if IP_FRAG 76 | #if !LWIP_NETIF_TX_SINGLE_PBUF 77 | #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED 78 | #define LWIP_PBUF_CUSTOM_REF_DEFINED 79 | /** A custom pbuf that holds a reference to another pbuf, which is freed 80 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 81 | * that points into the original pbuf. */ 82 | struct pbuf_custom_ref { 83 | /** 'base class' */ 84 | struct pbuf_custom pc; 85 | /** pointer to the original pbuf that is referenced */ 86 | struct pbuf *original; 87 | }; 88 | #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ 89 | #endif /* !LWIP_NETIF_TX_SINGLE_PBUF */ 90 | 91 | err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest); 92 | #endif /* IP_FRAG */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | 98 | #endif /* LWIP_IPV4 */ 99 | 100 | #endif /* LWIP_HDR_IP4_FRAG_H */ 101 | -------------------------------------------------------------------------------- /src/include/lwip/ip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 layer. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | #ifndef LWIP_HDR_IP6_H 42 | #define LWIP_HDR_IP6_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/ip6_addr.h" 49 | #include "lwip/prot/ip6.h" 50 | #include "lwip/def.h" 51 | #include "lwip/pbuf.h" 52 | #include "lwip/netif.h" 53 | 54 | #include "lwip/err.h" 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest); 61 | const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest); 62 | err_t ip6_input(struct pbuf *p, struct netif *inp); 63 | err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 64 | u8_t hl, u8_t tc, u8_t nexth); 65 | err_t ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 66 | u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); 67 | err_t ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 68 | u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); 69 | #if LWIP_NETIF_USE_HINTS 70 | err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 71 | u8_t hl, u8_t tc, u8_t nexth, struct netif_hint *netif_hint); 72 | #endif /* LWIP_NETIF_USE_HINTS */ 73 | #if LWIP_IPV6_MLD 74 | err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value); 75 | #endif /* LWIP_IPV6_MLD */ 76 | 77 | #define ip6_netif_get_local_ip(netif, dest) (((netif) != NULL) ? \ 78 | ip6_select_source_address(netif, dest) : NULL) 79 | 80 | #if IP6_DEBUG 81 | void ip6_debug_print(struct pbuf *p); 82 | #else 83 | #define ip6_debug_print(p) 84 | #endif /* IP6_DEBUG */ 85 | 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LWIP_IPV6 */ 92 | 93 | #endif /* LWIP_HDR_IP6_H */ 94 | -------------------------------------------------------------------------------- /src/include/lwip/mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Heap API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_MEM_H 38 | #define LWIP_HDR_MEM_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if MEM_CUSTOM_ALLOCATOR 47 | 48 | #include "lwip/arch.h" 49 | 50 | typedef size_t mem_size_t; 51 | #define MEM_SIZE_F SZT_F 52 | 53 | #elif MEM_USE_POOLS 54 | 55 | typedef u16_t mem_size_t; 56 | #define MEM_SIZE_F U16_F 57 | 58 | #else 59 | 60 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of 61 | * 65535 leaves some room for alignment... 62 | */ 63 | #if MEM_SIZE > 64000L 64 | typedef u32_t mem_size_t; 65 | #define MEM_SIZE_F U32_F 66 | #else 67 | typedef u16_t mem_size_t; 68 | #define MEM_SIZE_F U16_F 69 | #endif /* MEM_SIZE > 64000 */ 70 | #endif 71 | 72 | void mem_init(void); 73 | void *mem_trim(void *mem, mem_size_t size); 74 | void *mem_malloc(mem_size_t size); 75 | void *mem_calloc(mem_size_t count, mem_size_t size); 76 | void mem_free(void *mem); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* LWIP_HDR_MEM_H */ 83 | -------------------------------------------------------------------------------- /src/include/lwip/mld6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710. 5 | * No support for MLDv2. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2010 Inico Technologies Ltd. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Ivan Delamer 37 | * 38 | * 39 | * Please coordinate changes and requests with Ivan Delamer 40 | * 41 | */ 42 | 43 | #ifndef LWIP_HDR_MLD6_H 44 | #define LWIP_HDR_MLD6_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_IPV6_MLD && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 49 | 50 | #include "lwip/pbuf.h" 51 | #include "lwip/netif.h" 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** MLD group */ 58 | struct mld_group { 59 | /** next link */ 60 | struct mld_group *next; 61 | /** multicast address */ 62 | ip6_addr_t group_address; 63 | /** signifies we were the last person to report */ 64 | u8_t last_reporter_flag; 65 | /** current state of the group */ 66 | u8_t group_state; 67 | /** timer for reporting */ 68 | u16_t timer; 69 | /** counter of simultaneous uses */ 70 | u8_t use; 71 | }; 72 | 73 | #define MLD6_TMR_INTERVAL 100 /* Milliseconds */ 74 | 75 | err_t mld6_stop(struct netif *netif); 76 | void mld6_report_groups(struct netif *netif); 77 | void mld6_tmr(void); 78 | struct mld_group *mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr); 79 | void mld6_input(struct pbuf *p, struct netif *inp); 80 | err_t mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); 81 | err_t mld6_joingroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); 82 | err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); 83 | err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); 84 | 85 | /** @ingroup mld6 86 | * Get list head of MLD6 groups for netif. 87 | * Note: The allnodes group IP is NOT in the list, since it must always 88 | * be received for correct IPv6 operation. 89 | * @see @ref netif_set_mld_mac_filter() 90 | */ 91 | #define netif_mld6_data(netif) ((struct mld_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_MLD6)) 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_IPV6_MLD && LWIP_IPV6 */ 98 | 99 | #endif /* LWIP_HDR_MLD6_H */ 100 | -------------------------------------------------------------------------------- /src/include/lwip/nd6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Neighbor discovery and stateless address autoconfiguration for IPv6. 5 | * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 6 | * (Address autoconfiguration). 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2010 Inico Technologies Ltd. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Ivan Delamer 38 | * 39 | * 40 | * Please coordinate changes and requests with Ivan Delamer 41 | * 42 | */ 43 | 44 | #ifndef LWIP_HDR_ND6_H 45 | #define LWIP_HDR_ND6_H 46 | 47 | #include "lwip/opt.h" 48 | 49 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 50 | 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/err.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** 1 second period */ 59 | #define ND6_TMR_INTERVAL 1000 60 | 61 | /** Router solicitations are sent in 4 second intervals (see RFC 4861, ch. 6.3.7) */ 62 | #ifndef ND6_RTR_SOLICITATION_INTERVAL 63 | #define ND6_RTR_SOLICITATION_INTERVAL 4000 64 | #endif 65 | 66 | struct pbuf; 67 | struct netif; 68 | 69 | void nd6_tmr(void); 70 | void nd6_input(struct pbuf *p, struct netif *inp); 71 | void nd6_clear_destination_cache(void); 72 | struct netif *nd6_find_route(const ip6_addr_t *ip6addr); 73 | err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp); 74 | u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif); 75 | #if LWIP_ND6_TCP_REACHABILITY_HINTS 76 | void nd6_reachability_hint(const ip6_addr_t *ip6addr); 77 | #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ 78 | void nd6_cleanup_netif(struct netif *netif); 79 | #if LWIP_IPV6_MLD 80 | void nd6_adjust_mld_membership(struct netif *netif, s8_t addr_idx, u8_t new_state); 81 | #endif /* LWIP_IPV6_MLD */ 82 | void nd6_restart_netif(struct netif *netif); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* LWIP_IPV6 */ 89 | 90 | #endif /* LWIP_HDR_ND6_H */ 91 | -------------------------------------------------------------------------------- /src/include/lwip/priv/mem_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP internal memory implementations (do not use in application code) 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2018 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Simon Goldschmidt 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_MEM_PRIV_H 39 | #define LWIP_HDR_MEM_PRIV_H 40 | 41 | #include "lwip/opt.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #include "lwip/mem.h" 48 | 49 | #if MEM_OVERFLOW_CHECK || MEMP_OVERFLOW_CHECK 50 | /* if MEM_OVERFLOW_CHECK or MEMP_OVERFLOW_CHECK is turned on, we reserve some 51 | * bytes at the beginning and at the end of each element, initialize them as 52 | * 0xcd and check them later. 53 | * If MEM(P)_OVERFLOW_CHECK is >= 2, on every call to mem(p)_malloc or mem(p)_free, 54 | * every single element in each pool/heap is checked! 55 | * This is VERY SLOW but also very helpful. 56 | * MEM_SANITY_REGION_BEFORE and MEM_SANITY_REGION_AFTER can be overridden in 57 | * lwipopts.h to change the amount reserved for checking. */ 58 | #ifndef MEM_SANITY_REGION_BEFORE 59 | #define MEM_SANITY_REGION_BEFORE 16 60 | #endif /* MEM_SANITY_REGION_BEFORE*/ 61 | #if MEM_SANITY_REGION_BEFORE > 0 62 | #define MEM_SANITY_REGION_BEFORE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEM_SANITY_REGION_BEFORE) 63 | #else 64 | #define MEM_SANITY_REGION_BEFORE_ALIGNED 0 65 | #endif /* MEM_SANITY_REGION_BEFORE*/ 66 | #ifndef MEM_SANITY_REGION_AFTER 67 | #define MEM_SANITY_REGION_AFTER 16 68 | #endif /* MEM_SANITY_REGION_AFTER*/ 69 | #if MEM_SANITY_REGION_AFTER > 0 70 | #define MEM_SANITY_REGION_AFTER_ALIGNED LWIP_MEM_ALIGN_SIZE(MEM_SANITY_REGION_AFTER) 71 | #else 72 | #define MEM_SANITY_REGION_AFTER_ALIGNED 0 73 | #endif /* MEM_SANITY_REGION_AFTER*/ 74 | 75 | void mem_overflow_init_raw(void *p, size_t size); 76 | void mem_overflow_check_raw(void *p, size_t size, const char *descr1, const char *descr2); 77 | 78 | #endif /* MEM_OVERFLOW_CHECK || MEMP_OVERFLOW_CHECK */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* LWIP_HDR_MEMP_PRIV_H */ 85 | -------------------------------------------------------------------------------- /src/include/lwip/priv/raw_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * raw API internal implementations (do not use in application code) 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_RAW_PRIV_H 38 | #define LWIP_HDR_RAW_PRIV_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 43 | 44 | #include "lwip/raw.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /** return codes for raw_input */ 51 | typedef enum raw_input_state 52 | { 53 | RAW_INPUT_NONE = 0, /* pbuf did not match any pcbs */ 54 | RAW_INPUT_EATEN, /* pbuf handed off and delivered to pcb */ 55 | RAW_INPUT_DELIVERED /* pbuf only delivered to pcb (pbuf can still be referenced) */ 56 | } raw_input_state_t; 57 | 58 | /* The following functions are the lower layer interface to RAW. */ 59 | raw_input_state_t raw_input(struct pbuf *p, struct netif *inp); 60 | 61 | void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* LWIP_RAW */ 68 | 69 | #endif /* LWIP_HDR_RAW_PRIV_H */ 70 | -------------------------------------------------------------------------------- /src/include/lwip/prot/autoip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * AutoIP protocol definitions 4 | */ 5 | 6 | /* 7 | * 8 | * Copyright (c) 2007 Dominik Spies 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * Author: Dominik Spies 34 | * 35 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 36 | * with RFC 3927. 37 | * 38 | */ 39 | 40 | #ifndef LWIP_HDR_PROT_AUTOIP_H 41 | #define LWIP_HDR_PROT_AUTOIP_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 169.254.0.0 */ 48 | #define AUTOIP_NET 0xA9FE0000 49 | /* 169.254.1.0 */ 50 | #define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) 51 | /* 169.254.254.255 */ 52 | #define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) 53 | 54 | /* AutoIP client states */ 55 | typedef enum { 56 | AUTOIP_STATE_OFF, 57 | AUTOIP_STATE_CHECKING, 58 | AUTOIP_STATE_BOUND 59 | } autoip_state_enum_t; 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* LWIP_HDR_PROT_AUTOIP_H */ 66 | -------------------------------------------------------------------------------- /src/include/lwip/prot/iana.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IANA assigned numbers (RFC 1700 and successors) 4 | * 5 | * @defgroup iana IANA assigned numbers 6 | * @ingroup infrastructure 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2017 Dirk Ziegelmeier. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Dirk Ziegelmeier 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_PROT_IANA_H 42 | #define LWIP_HDR_PROT_IANA_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** 49 | * @ingroup iana 50 | * Hardware types 51 | */ 52 | enum lwip_iana_hwtype { 53 | /** Ethernet */ 54 | LWIP_IANA_HWTYPE_ETHERNET = 1 55 | }; 56 | 57 | /** 58 | * @ingroup iana 59 | * Port numbers 60 | * https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt 61 | */ 62 | enum lwip_iana_port_number { 63 | /** SMTP */ 64 | LWIP_IANA_PORT_SMTP = 25, 65 | /** DHCP server */ 66 | LWIP_IANA_PORT_DHCP_SERVER = 67, 67 | /** DHCP client */ 68 | LWIP_IANA_PORT_DHCP_CLIENT = 68, 69 | /** TFTP */ 70 | LWIP_IANA_PORT_TFTP = 69, 71 | /** HTTP */ 72 | LWIP_IANA_PORT_HTTP = 80, 73 | /** SNTP */ 74 | LWIP_IANA_PORT_SNTP = 123, 75 | /** NETBIOS */ 76 | LWIP_IANA_PORT_NETBIOS = 137, 77 | /** SNMP */ 78 | LWIP_IANA_PORT_SNMP = 161, 79 | /** SNMP traps */ 80 | LWIP_IANA_PORT_SNMP_TRAP = 162, 81 | /** HTTPS */ 82 | LWIP_IANA_PORT_HTTPS = 443, 83 | /** SMTPS */ 84 | LWIP_IANA_PORT_SMTPS = 465, 85 | /** MQTT */ 86 | LWIP_IANA_PORT_MQTT = 1883, 87 | /** MDNS */ 88 | LWIP_IANA_PORT_MDNS = 5353, 89 | /** Secure MQTT */ 90 | LWIP_IANA_PORT_SECURE_MQTT = 8883 91 | }; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_HDR_PROT_IANA_H */ 98 | -------------------------------------------------------------------------------- /src/include/lwip/prot/icmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * ICMP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_ICMP_H 38 | #define LWIP_HDR_PROT_ICMP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define ICMP_ER 0 /* echo reply */ 47 | #define ICMP_DUR 3 /* destination unreachable */ 48 | #define ICMP_SQ 4 /* source quench */ 49 | #define ICMP_RD 5 /* redirect */ 50 | #define ICMP_ECHO 8 /* echo */ 51 | #define ICMP_TE 11 /* time exceeded */ 52 | #define ICMP_PP 12 /* parameter problem */ 53 | #define ICMP_TS 13 /* timestamp */ 54 | #define ICMP_TSR 14 /* timestamp reply */ 55 | #define ICMP_IRQ 15 /* information request */ 56 | #define ICMP_IR 16 /* information reply */ 57 | #define ICMP_AM 17 /* address mask request */ 58 | #define ICMP_AMR 18 /* address mask reply */ 59 | 60 | #ifdef PACK_STRUCT_USE_INCLUDES 61 | # include "arch/bpstruct.h" 62 | #endif 63 | /** The standard ICMP header (unspecified 32 bit data) */ 64 | PACK_STRUCT_BEGIN 65 | struct icmp_hdr { 66 | PACK_STRUCT_FLD_8(u8_t type); 67 | PACK_STRUCT_FLD_8(u8_t code); 68 | PACK_STRUCT_FIELD(u16_t chksum); 69 | PACK_STRUCT_FIELD(u32_t data); 70 | } PACK_STRUCT_STRUCT; 71 | PACK_STRUCT_END 72 | #ifdef PACK_STRUCT_USE_INCLUDES 73 | # include "arch/epstruct.h" 74 | #endif 75 | 76 | /* Compatibility defines, old versions used to combine type and code to an u16_t */ 77 | #define ICMPH_TYPE(hdr) ((hdr)->type) 78 | #define ICMPH_CODE(hdr) ((hdr)->code) 79 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) 80 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) 81 | 82 | #ifdef PACK_STRUCT_USE_INCLUDES 83 | # include "arch/bpstruct.h" 84 | #endif 85 | /** This is the standard ICMP header only that the u32_t data 86 | * is split to two u16_t like ICMP echo needs it. 87 | */ 88 | PACK_STRUCT_BEGIN 89 | struct icmp_echo_hdr { 90 | PACK_STRUCT_FLD_8(u8_t type); 91 | PACK_STRUCT_FLD_8(u8_t code); 92 | PACK_STRUCT_FIELD(u16_t chksum); 93 | PACK_STRUCT_FIELD(u16_t id); 94 | PACK_STRUCT_FIELD(u16_t seqno); 95 | } PACK_STRUCT_STRUCT; 96 | PACK_STRUCT_END 97 | #ifdef PACK_STRUCT_USE_INCLUDES 98 | # include "arch/epstruct.h" 99 | #endif 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* LWIP_HDR_PROT_ICMP_H */ 106 | -------------------------------------------------------------------------------- /src/include/lwip/prot/ieee.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IEEE assigned numbers 4 | * 5 | * @defgroup ieee IEEE assigned numbers 6 | * @ingroup infrastructure 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2017 Dirk Ziegelmeier. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Dirk Ziegelmeier 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_PROT_IEEE_H 42 | #define LWIP_HDR_PROT_IEEE_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** 49 | * @ingroup ieee 50 | * A list of often ethtypes (although lwIP does not use all of them). 51 | */ 52 | enum lwip_ieee_eth_type { 53 | /** Internet protocol v4 */ 54 | ETHTYPE_IP = 0x0800U, 55 | /** Address resolution protocol */ 56 | ETHTYPE_ARP = 0x0806U, 57 | /** Wake on lan */ 58 | ETHTYPE_WOL = 0x0842U, 59 | /** RARP */ 60 | ETHTYPE_RARP = 0x8035U, 61 | /** Virtual local area network */ 62 | ETHTYPE_VLAN = 0x8100U, 63 | /** Internet protocol v6 */ 64 | ETHTYPE_IPV6 = 0x86DDU, 65 | /** PPP Over Ethernet Discovery Stage */ 66 | ETHTYPE_PPPOEDISC = 0x8863U, 67 | /** PPP Over Ethernet Session Stage */ 68 | ETHTYPE_PPPOE = 0x8864U, 69 | /** Jumbo Frames */ 70 | ETHTYPE_JUMBO = 0x8870U, 71 | /** Process field network */ 72 | ETHTYPE_PROFINET = 0x8892U, 73 | /** Ethernet for control automation technology */ 74 | ETHTYPE_ETHERCAT = 0x88A4U, 75 | /** Link layer discovery protocol */ 76 | ETHTYPE_LLDP = 0x88CCU, 77 | /** Serial real-time communication system */ 78 | ETHTYPE_SERCOS = 0x88CDU, 79 | /** Media redundancy protocol */ 80 | ETHTYPE_MRP = 0x88E3U, 81 | /** Precision time protocol */ 82 | ETHTYPE_PTP = 0x88F7U, 83 | /** Q-in-Q, 802.1ad */ 84 | ETHTYPE_QINQ = 0x9100U 85 | }; 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LWIP_HDR_PROT_IEEE_H */ 92 | -------------------------------------------------------------------------------- /src/include/lwip/prot/igmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IGMP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IGMP_H 38 | #define LWIP_HDR_PROT_IGMP_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/prot/ip4.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 48 | * IGMP constants 49 | */ 50 | #define IGMP_TTL 1 51 | #define IGMP_MINLEN 8 52 | #define ROUTER_ALERT 0x9404U 53 | #define ROUTER_ALERTLEN 4 54 | 55 | /* 56 | * IGMP message types, including version number. 57 | */ 58 | #define IGMP_MEMB_QUERY 0x11 /* Membership query */ 59 | #define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */ 60 | #define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */ 61 | #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ 62 | 63 | /* Group membership states */ 64 | #define IGMP_GROUP_NON_MEMBER 0 65 | #define IGMP_GROUP_DELAYING_MEMBER 1 66 | #define IGMP_GROUP_IDLE_MEMBER 2 67 | 68 | /** 69 | * IGMP packet format. 70 | */ 71 | #ifdef PACK_STRUCT_USE_INCLUDES 72 | # include "arch/bpstruct.h" 73 | #endif 74 | PACK_STRUCT_BEGIN 75 | struct igmp_msg { 76 | PACK_STRUCT_FLD_8(u8_t igmp_msgtype); 77 | PACK_STRUCT_FLD_8(u8_t igmp_maxresp); 78 | PACK_STRUCT_FIELD(u16_t igmp_checksum); 79 | PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address); 80 | } PACK_STRUCT_STRUCT; 81 | PACK_STRUCT_END 82 | #ifdef PACK_STRUCT_USE_INCLUDES 83 | # include "arch/epstruct.h" 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* LWIP_HDR_PROT_IGMP_H */ 91 | -------------------------------------------------------------------------------- /src/include/lwip/prot/ip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IP_H 38 | #define LWIP_HDR_PROT_IP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define IP_PROTO_ICMP 1 47 | #define IP_PROTO_IGMP 2 48 | #define IP_PROTO_UDP 17 49 | #define IP_PROTO_UDPLITE 136 50 | #define IP_PROTO_TCP 6 51 | 52 | /** This operates on a void* by loading the first byte */ 53 | #define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4) 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* LWIP_HDR_PROT_IP_H */ 60 | -------------------------------------------------------------------------------- /src/include/lwip/prot/mld6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MLD6 protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_MLD6_H 38 | #define LWIP_HDR_PROT_MLD6_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/prot/ip6.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #define MLD6_HBH_HLEN 8 48 | /** Multicast listener report/query/done message header. */ 49 | #ifdef PACK_STRUCT_USE_INCLUDES 50 | # include "arch/bpstruct.h" 51 | #endif 52 | PACK_STRUCT_BEGIN 53 | struct mld_header { 54 | PACK_STRUCT_FLD_8(u8_t type); 55 | PACK_STRUCT_FLD_8(u8_t code); 56 | PACK_STRUCT_FIELD(u16_t chksum); 57 | PACK_STRUCT_FIELD(u16_t max_resp_delay); 58 | PACK_STRUCT_FIELD(u16_t reserved); 59 | PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); 60 | /* Options follow. */ 61 | } PACK_STRUCT_STRUCT; 62 | PACK_STRUCT_END 63 | #ifdef PACK_STRUCT_USE_INCLUDES 64 | # include "arch/epstruct.h" 65 | #endif 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* LWIP_HDR_PROT_MLD6_H */ 72 | -------------------------------------------------------------------------------- /src/include/lwip/prot/tcp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * TCP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_TCP_H 38 | #define LWIP_HDR_PROT_TCP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Length of the TCP header, excluding options. */ 47 | #define TCP_HLEN 20 48 | 49 | /* Fields are (of course) in network byte order. 50 | * Some fields are converted to host byte order in tcp_input(). 51 | */ 52 | #ifdef PACK_STRUCT_USE_INCLUDES 53 | # include "arch/bpstruct.h" 54 | #endif 55 | PACK_STRUCT_BEGIN 56 | struct tcp_hdr { 57 | PACK_STRUCT_FIELD(u16_t src); 58 | PACK_STRUCT_FIELD(u16_t dest); 59 | PACK_STRUCT_FIELD(u32_t seqno); 60 | PACK_STRUCT_FIELD(u32_t ackno); 61 | PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); 62 | PACK_STRUCT_FIELD(u16_t wnd); 63 | PACK_STRUCT_FIELD(u16_t chksum); 64 | PACK_STRUCT_FIELD(u16_t urgp); 65 | } PACK_STRUCT_STRUCT; 66 | PACK_STRUCT_END 67 | #ifdef PACK_STRUCT_USE_INCLUDES 68 | # include "arch/epstruct.h" 69 | #endif 70 | 71 | /* TCP header flags bits */ 72 | #define TCP_FIN 0x01U 73 | #define TCP_SYN 0x02U 74 | #define TCP_RST 0x04U 75 | #define TCP_PSH 0x08U 76 | #define TCP_ACK 0x10U 77 | #define TCP_URG 0x20U 78 | #define TCP_ECE 0x40U 79 | #define TCP_CWR 0x80U 80 | /* Valid TCP header flags */ 81 | #define TCP_FLAGS 0x3fU 82 | 83 | #define TCP_MAX_OPTION_BYTES 40 84 | 85 | #define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) 86 | #define TCPH_HDRLEN_BYTES(phdr) ((u8_t)(TCPH_HDRLEN(phdr) << 2)) 87 | #define TCPH_FLAGS(phdr) ((u8_t)((lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS))) 88 | 89 | #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr)) 90 | #define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags)) 91 | #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = (u16_t)(lwip_htons((u16_t)((len) << 12) | (flags))) 92 | 93 | #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags)) 94 | #define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags)) 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* LWIP_HDR_PROT_TCP_H */ 101 | -------------------------------------------------------------------------------- /src/include/lwip/prot/udp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * UDP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_UDP_H 38 | #define LWIP_HDR_PROT_UDP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define UDP_HLEN 8 47 | 48 | /* Fields are (of course) in network byte order. */ 49 | #ifdef PACK_STRUCT_USE_INCLUDES 50 | # include "arch/bpstruct.h" 51 | #endif 52 | PACK_STRUCT_BEGIN 53 | struct udp_hdr { 54 | PACK_STRUCT_FIELD(u16_t src); 55 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 56 | PACK_STRUCT_FIELD(u16_t len); 57 | PACK_STRUCT_FIELD(u16_t chksum); 58 | } PACK_STRUCT_STRUCT; 59 | PACK_STRUCT_END 60 | #ifdef PACK_STRUCT_USE_INCLUDES 61 | # include "arch/epstruct.h" 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* LWIP_HDR_PROT_UDP_H */ 69 | -------------------------------------------------------------------------------- /src/include/lwip/tcpbase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Base TCP API definitions shared by TCP and ALTCP
4 | * See also @ref tcp_raw 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | #ifndef LWIP_HDR_TCPBASE_H 39 | #define LWIP_HDR_TCPBASE_H 40 | 41 | #include "lwip/opt.h" 42 | 43 | #if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | 50 | #if LWIP_WND_SCALE 51 | typedef u32_t tcpwnd_size_t; 52 | #else 53 | typedef u16_t tcpwnd_size_t; 54 | #endif 55 | 56 | enum tcp_state { 57 | CLOSED = 0, 58 | LISTEN = 1, 59 | SYN_SENT = 2, 60 | SYN_RCVD = 3, 61 | ESTABLISHED = 4, 62 | FIN_WAIT_1 = 5, 63 | FIN_WAIT_2 = 6, 64 | CLOSE_WAIT = 7, 65 | CLOSING = 8, 66 | LAST_ACK = 9, 67 | TIME_WAIT = 10 68 | }; 69 | /* ATTENTION: this depends on state number ordering! */ 70 | #define TCP_STATE_IS_CLOSING(state) ((state) >= FIN_WAIT_1) 71 | 72 | /* Flags for "apiflags" parameter in tcp_write */ 73 | #define TCP_WRITE_FLAG_COPY 0x01 74 | #define TCP_WRITE_FLAG_MORE 0x02 75 | 76 | #define TCP_PRIO_MIN 1 77 | #define TCP_PRIO_NORMAL 64 78 | #define TCP_PRIO_MAX 127 79 | 80 | const char* tcp_debug_state_str(enum tcp_state s); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* LWIP_TCP */ 87 | 88 | #endif /* LWIP_HDR_TCPBASE_H */ 89 | -------------------------------------------------------------------------------- /src/include/netif/bridgeif_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP netif implementing an IEEE 802.1D MAC Bridge 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Simon Goldschmidt. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Simon Goldschmidt 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_NETIF_BRIDGEIF_OPTS_H 39 | #define LWIP_HDR_NETIF_BRIDGEIF_OPTS_H 40 | 41 | #include "lwip/opt.h" 42 | 43 | /** 44 | * @defgroup bridgeif_opts Options 45 | * @ingroup bridgeif 46 | * @{ 47 | */ 48 | 49 | /** BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT==1: set port netif's 'input' function 50 | * to call directly into bridgeif code and on top of that, directly call into 51 | * the selected forwarding port's 'linkoutput' function. 52 | * This means that the bridgeif input/output path is protected from concurrent access 53 | * but as well, *all* bridge port netif's drivers must correctly handle concurrent access! 54 | * == 0: get into tcpip_thread for every input packet (no multithreading) 55 | * ATTENTION: as ==0 relies on tcpip.h, the default depends on NO_SYS setting 56 | */ 57 | #ifndef BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT 58 | #define BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT NO_SYS 59 | #endif 60 | 61 | /** BRIDGEIF_MAX_PORTS: this is used to create a typedef used for forwarding 62 | * bit-fields: the number of bits required is this + 1 (for the internal/cpu port) 63 | * (63 is the maximum, resulting in an u64_t for the bit mask) 64 | * ATTENTION: this controls the maximum number of the implementation only! 65 | * The max. number of ports per bridge must still be passed via netif_add parameter! 66 | */ 67 | #ifndef BRIDGEIF_MAX_PORTS 68 | #define BRIDGEIF_MAX_PORTS 7 69 | #endif 70 | 71 | /** BRIDGEIF_DEBUG: Enable generic debugging in bridgeif.c. */ 72 | #ifndef BRIDGEIF_DEBUG 73 | #define BRIDGEIF_DEBUG LWIP_DBG_OFF 74 | #endif 75 | 76 | /** BRIDGEIF_DEBUG: Enable FDB debugging in bridgeif.c. */ 77 | #ifndef BRIDGEIF_FDB_DEBUG 78 | #define BRIDGEIF_FDB_DEBUG LWIP_DBG_OFF 79 | #endif 80 | 81 | /** BRIDGEIF_DEBUG: Enable forwarding debugging in bridgeif.c. */ 82 | #ifndef BRIDGEIF_FW_DEBUG 83 | #define BRIDGEIF_FW_DEBUG LWIP_DBG_OFF 84 | #endif 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | #endif /* LWIP_HDR_NETIF_BRIDGEIF_OPTS_H */ 91 | -------------------------------------------------------------------------------- /src/include/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* ARP has been moved to core/ipv4, provide this #include for compatibility only */ 2 | #include "lwip/etharp.h" 3 | #include "netif/ethernet.h" 4 | -------------------------------------------------------------------------------- /src/include/netif/ethernet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Ethernet input function - handles INCOMING ethernet level traffic 4 | * To be used in most low-level netif implementations 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 9 | * Copyright (c) 2003-2004 Leon Woestenberg 10 | * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Adam Dunkels 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_NETIF_ETHERNET_H 42 | #define LWIP_HDR_NETIF_ETHERNET_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #include "lwip/pbuf.h" 47 | #include "lwip/netif.h" 48 | #include "lwip/prot/ethernet.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if LWIP_ARP || LWIP_ETHERNET 55 | 56 | /** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) 57 | * to a filter function that returns the correct netif when using multiple 58 | * netifs on one hardware interface where the netif's low-level receive 59 | * routine cannot decide for the correct netif (e.g. when mapping multiple 60 | * IP addresses to one hardware interface). 61 | */ 62 | #ifndef LWIP_ARP_FILTER_NETIF 63 | #define LWIP_ARP_FILTER_NETIF 0 64 | #endif 65 | 66 | err_t ethernet_input(struct pbuf *p, struct netif *netif); 67 | err_t ethernet_output(struct netif* netif, struct pbuf* p, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type); 68 | 69 | extern const struct eth_addr ethbroadcast, ethzero; 70 | 71 | #endif /* LWIP_ARP || LWIP_ETHERNET */ 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* LWIP_HDR_NETIF_ETHERNET_H */ 78 | -------------------------------------------------------------------------------- /src/include/netif/lowpan6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * 6LowPAN output for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2015 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_LOWPAN6_H 43 | #define LWIP_HDR_LOWPAN6_H 44 | 45 | #include "netif/lowpan6_opts.h" 46 | 47 | #if LWIP_IPV6 48 | 49 | #include "netif/lowpan6_common.h" 50 | #include "lwip/pbuf.h" 51 | #include "lwip/ip.h" 52 | #include "lwip/ip_addr.h" 53 | #include "lwip/netif.h" 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /** 1 second period for reassembly */ 60 | #define LOWPAN6_TMR_INTERVAL 1000 61 | 62 | void lowpan6_tmr(void); 63 | 64 | err_t lowpan6_set_context(u8_t idx, const ip6_addr_t * context); 65 | err_t lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low); 66 | 67 | #if LWIP_IPV4 68 | err_t lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); 69 | #endif /* LWIP_IPV4 */ 70 | err_t lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 71 | err_t lowpan6_input(struct pbuf * p, struct netif *netif); 72 | err_t lowpan6_if_init(struct netif *netif); 73 | 74 | /* pan_id in network byte order. */ 75 | err_t lowpan6_set_pan_id(u16_t pan_id); 76 | 77 | u16_t lowpan6_calc_crc(const void *buf, u16_t len); 78 | 79 | #if !NO_SYS 80 | err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp); 81 | #endif /* !NO_SYS */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* LWIP_IPV6 */ 88 | 89 | #endif /* LWIP_HDR_LOWPAN6_H */ 90 | -------------------------------------------------------------------------------- /src/include/netif/lowpan6_ble.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 6LowPAN over BLE for IPv6 (RFC7668). 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Benjamin Aigner 8 | * Copyright (c) 2015 Inico Technologies Ltd. , Author: Ivan Delamer 9 | * 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * Author: Benjamin Aigner 35 | * 36 | * Based on the original 6lowpan implementation of lwIP ( @see 6lowpan.c) 37 | */ 38 | 39 | #ifndef LWIP_HDR_LOWPAN6_BLE_H 40 | #define LWIP_HDR_LOWPAN6_BLE_H 41 | 42 | #include "netif/lowpan6_opts.h" 43 | 44 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "netif/lowpan6_common.h" 47 | #include "lwip/pbuf.h" 48 | #include "lwip/ip.h" 49 | #include "lwip/ip_addr.h" 50 | #include "lwip/netif.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | err_t rfc7668_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 57 | err_t rfc7668_input(struct pbuf * p, struct netif *netif); 58 | err_t rfc7668_set_local_addr_eui64(struct netif *netif, const u8_t *local_addr, size_t local_addr_len); 59 | err_t rfc7668_set_local_addr_mac48(struct netif *netif, const u8_t *local_addr, size_t local_addr_len, int is_public_addr); 60 | err_t rfc7668_set_peer_addr_eui64(struct netif *netif, const u8_t *peer_addr, size_t peer_addr_len); 61 | err_t rfc7668_set_peer_addr_mac48(struct netif *netif, const u8_t *peer_addr, size_t peer_addr_len, int is_public_addr); 62 | err_t rfc7668_set_context(u8_t index, const ip6_addr_t * context); 63 | err_t rfc7668_if_init(struct netif *netif); 64 | 65 | #if !NO_SYS 66 | err_t tcpip_rfc7668_input(struct pbuf *p, struct netif *inp); 67 | #endif 68 | 69 | void ble_addr_to_eui64(u8_t *dst, const u8_t *src, int public_addr); 70 | void eui64_to_ble_addr(u8_t *dst, const u8_t *src); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* LWIP_IPV6 */ 77 | 78 | #endif /* LWIP_HDR_LOWPAN6_BLE_H */ 79 | -------------------------------------------------------------------------------- /src/include/netif/lowpan6_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Common 6LowPAN routines for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2015 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_LOWPAN6_COMMON_H 43 | #define LWIP_HDR_LOWPAN6_COMMON_H 44 | 45 | #include "netif/lowpan6_opts.h" 46 | 47 | #if LWIP_IPV6 /* don't build if IPv6 is disabled in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** Helper define for a link layer address, which can be encoded as 0, 2 or 8 bytes */ 59 | struct lowpan6_link_addr { 60 | /* encoded length of the address */ 61 | u8_t addr_len; 62 | /* address bytes */ 63 | u8_t addr[8]; 64 | }; 65 | 66 | s8_t lowpan6_get_address_mode(const ip6_addr_t *ip6addr, const struct lowpan6_link_addr *mac_addr); 67 | 68 | #if LWIP_6LOWPAN_IPHC 69 | err_t lowpan6_compress_headers(struct netif *netif, u8_t *inbuf, size_t inbuf_size, u8_t *outbuf, size_t outbuf_size, 70 | u8_t *lowpan6_header_len_out, u8_t *hidden_header_len_out, ip6_addr_t *lowpan6_contexts, 71 | const struct lowpan6_link_addr *src, const struct lowpan6_link_addr *dst); 72 | struct pbuf *lowpan6_decompress(struct pbuf *p, u16_t datagram_size, ip6_addr_t *lowpan6_contexts, 73 | struct lowpan6_link_addr *src, struct lowpan6_link_addr *dest); 74 | #endif /* LWIP_6LOWPAN_IPHC */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* LWIP_IPV6 */ 81 | 82 | #endif /* LWIP_HDR_LOWPAN6_COMMON_H */ 83 | -------------------------------------------------------------------------------- /src/include/netif/ppp/chap-md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap-md5.h - New CHAP/MD5 implementation. 3 | * 4 | * Copyright (c) 2003 Paul Mackerras. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. The name(s) of the authors of this software must not be used to 14 | * endorse or promote products derived from this software without 15 | * prior written permission. 16 | * 17 | * 3. Redistributions of any form whatsoever must retain the following 18 | * acknowledgment: 19 | * "This product includes software developed by Paul Mackerras 20 | * ". 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | */ 30 | 31 | #include "netif/ppp/ppp_opts.h" 32 | #if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 33 | 34 | extern const struct chap_digest_type md5_digest; 35 | 36 | #endif /* PPP_SUPPORT && CHAP_SUPPORT */ 37 | -------------------------------------------------------------------------------- /src/include/netif/ppp/chap_ms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap_ms.h - Challenge Handshake Authentication Protocol definitions. 3 | * 4 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 35 | 36 | #ifndef CHAPMS_INCLUDE 37 | #define CHAPMS_INCLUDE 38 | 39 | extern const struct chap_digest_type chapms_digest; 40 | extern const struct chap_digest_type chapms2_digest; 41 | 42 | #endif /* CHAPMS_INCLUDE */ 43 | 44 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 45 | -------------------------------------------------------------------------------- /src/include/netif/ppp/ecp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ecp.h - Definitions for PPP Encryption Control Protocol. 3 | * 4 | * Copyright (c) 2002 Google, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. The name(s) of the authors of this software must not be used to 20 | * endorse or promote products derived from this software without 21 | * prior written permission. 22 | * 23 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 24 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 25 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 27 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 28 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 29 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 30 | * 31 | * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ 32 | */ 33 | 34 | #include "netif/ppp/ppp_opts.h" 35 | #if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 36 | 37 | #ifndef ECP_H 38 | #define ECP_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef struct ecp_options { 45 | bool required; /* Is ECP required? */ 46 | unsigned enctype; /* Encryption type */ 47 | } ecp_options; 48 | 49 | extern fsm ecp_fsm[]; 50 | extern ecp_options ecp_wantoptions[]; 51 | extern ecp_options ecp_gotoptions[]; 52 | extern ecp_options ecp_allowoptions[]; 53 | extern ecp_options ecp_hisoptions[]; 54 | 55 | extern const struct protent ecp_protent; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* ECP_H */ 62 | #endif /* PPP_SUPPORT && ECP_SUPPORT */ 63 | -------------------------------------------------------------------------------- /src/include/netif/ppp/eui64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.h - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #ifndef EUI64_H 42 | #define EUI64_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* 49 | * @todo: 50 | * 51 | * Maybe this should be done by processing struct in6_addr directly... 52 | */ 53 | typedef union 54 | { 55 | u8_t e8[8]; 56 | u16_t e16[4]; 57 | u32_t e32[2]; 58 | } eui64_t; 59 | 60 | #define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) 61 | #define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ 62 | ((e).e32[1] == (o).e32[1])) 63 | #define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0; 64 | 65 | #define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t)) 66 | 67 | #define eui64_magic(e) do { \ 68 | (e).e32[0] = magic(); \ 69 | (e).e32[1] = magic(); \ 70 | (e).e8[0] &= ~2; \ 71 | } while (0) 72 | #define eui64_magic_nz(x) do { \ 73 | eui64_magic(x); \ 74 | } while (eui64_iszero(x)) 75 | #define eui64_magic_ne(x, y) do { \ 76 | eui64_magic(x); \ 77 | } while (eui64_equals(x, y)) 78 | 79 | #define eui64_get(ll, cp) do { \ 80 | eui64_copy((*cp), (ll)); \ 81 | (cp) += sizeof(eui64_t); \ 82 | } while (0) 83 | 84 | #define eui64_put(ll, cp) do { \ 85 | eui64_copy((ll), (*cp)); \ 86 | (cp) += sizeof(eui64_t); \ 87 | } while (0) 88 | 89 | #define eui64_set32(e, l) do { \ 90 | (e).e32[0] = 0; \ 91 | (e).e32[1] = lwip_htonl(l); \ 92 | } while (0) 93 | #define eui64_setlo32(e, l) eui64_set32(e, l) 94 | 95 | char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* EUI64_H */ 102 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 103 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/arc4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file arc4.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_ARC4 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_ARC4_H 40 | #define LWIP_INCLUDED_POLARSSL_ARC4_H 41 | 42 | /** 43 | * \brief ARC4 context structure 44 | */ 45 | typedef struct 46 | { 47 | int x; /*!< permutation index */ 48 | int y; /*!< permutation index */ 49 | unsigned char m[256]; /*!< permutation table */ 50 | } 51 | arc4_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief ARC4 key schedule 59 | * 60 | * \param ctx ARC4 context to be initialized 61 | * \param key the secret key 62 | * \param keylen length of the key 63 | */ 64 | void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); 65 | 66 | /** 67 | * \brief ARC4 cipher function 68 | * 69 | * \param ctx ARC4 context 70 | * \param buf buffer to be processed 71 | * \param buflen amount of data in buf 72 | */ 73 | void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */ 80 | 81 | #endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ 82 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/des.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file des.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_DES 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_DES_H 40 | #define LWIP_INCLUDED_POLARSSL_DES_H 41 | 42 | #define DES_ENCRYPT 1 43 | #define DES_DECRYPT 0 44 | 45 | /** 46 | * \brief DES context structure 47 | */ 48 | typedef struct 49 | { 50 | int mode; /*!< encrypt/decrypt */ 51 | unsigned long sk[32]; /*!< DES subkeys */ 52 | } 53 | des_context; 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /** 60 | * \brief DES key schedule (56-bit, encryption) 61 | * 62 | * \param ctx DES context to be initialized 63 | * \param key 8-byte secret key 64 | */ 65 | void des_setkey_enc( des_context *ctx, unsigned char key[8] ); 66 | 67 | /** 68 | * \brief DES key schedule (56-bit, decryption) 69 | * 70 | * \param ctx DES context to be initialized 71 | * \param key 8-byte secret key 72 | */ 73 | void des_setkey_dec( des_context *ctx, unsigned char key[8] ); 74 | 75 | /** 76 | * \brief DES-ECB block encryption/decryption 77 | * 78 | * \param ctx DES context 79 | * \param input 64-bit input block 80 | * \param output 64-bit output block 81 | */ 82 | void des_crypt_ecb( des_context *ctx, 83 | const unsigned char input[8], 84 | unsigned char output[8] ); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* LWIP_INCLUDED_POLARSSL_DES_H */ 91 | 92 | #endif /* LWIP_INCLUDED_POLARSSL_DES */ 93 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/md4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md4.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_MD4 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_MD4_H 40 | #define LWIP_INCLUDED_POLARSSL_MD4_H 41 | 42 | /** 43 | * \brief MD4 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[4]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | md4_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief MD4 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void md4_starts( md4_context *ctx ); 63 | 64 | /** 65 | * \brief MD4 process buffer 66 | * 67 | * \param ctx MD4 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief MD4 final digest 75 | * 76 | * \param ctx MD4 context 77 | * \param output MD4 checksum result 78 | */ 79 | void md4_finish( md4_context *ctx, unsigned char output[16] ); 80 | 81 | /** 82 | * \brief Output = MD4( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output MD4 checksum result 87 | */ 88 | void md4( unsigned char *input, int ilen, unsigned char output[16] ); 89 | 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* LWIP_INCLUDED_POLARSSL_MD4_H */ 96 | 97 | #endif /* LWIP_INCLUDED_POLARSSL_MD4 */ 98 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/md5.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md5.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_MD5 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_MD5_H 40 | #define LWIP_INCLUDED_POLARSSL_MD5_H 41 | 42 | /** 43 | * \brief MD5 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[4]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | md5_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief MD5 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void md5_starts( md5_context *ctx ); 63 | 64 | /** 65 | * \brief MD5 process buffer 66 | * 67 | * \param ctx MD5 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief MD5 final digest 75 | * 76 | * \param ctx MD5 context 77 | * \param output MD5 checksum result 78 | */ 79 | void md5_finish( md5_context *ctx, unsigned char output[16] ); 80 | 81 | /** 82 | * \brief Output = MD5( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output MD5 checksum result 87 | */ 88 | void md5( unsigned char *input, int ilen, unsigned char output[16] ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ 95 | 96 | #endif /* LWIP_INCLUDED_POLARSSL_MD5 */ 97 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/sha1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file sha1.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_SHA1 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_SHA1_H 40 | #define LWIP_INCLUDED_POLARSSL_SHA1_H 41 | 42 | /** 43 | * \brief SHA-1 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[5]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | sha1_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief SHA-1 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void sha1_starts( sha1_context *ctx ); 63 | 64 | /** 65 | * \brief SHA-1 process buffer 66 | * 67 | * \param ctx SHA-1 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief SHA-1 final digest 75 | * 76 | * \param ctx SHA-1 context 77 | * \param output SHA-1 checksum result 78 | */ 79 | void sha1_finish( sha1_context *ctx, unsigned char output[20] ); 80 | 81 | /** 82 | * \brief Output = SHA-1( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output SHA-1 checksum result 87 | */ 88 | void sha1( unsigned char *input, int ilen, unsigned char output[20] ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ 95 | 96 | #endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ 97 | -------------------------------------------------------------------------------- /src/include/netif/ppp/pppdebug.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pppdebug.h - System debugging utilities. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * portions Copyright (c) 2001 by Cognizant Pty Ltd. 7 | * 8 | * The authors hereby grant permission to use, copy, modify, distribute, 9 | * and license this software and its documentation for any purpose, provided 10 | * that existing copyright notices are retained in all copies and that this 11 | * notice and the following disclaimer are included verbatim in any 12 | * distributions. No written agreement, license, or royalty fee is required 13 | * for any of the authorized uses. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | ****************************************************************************** 27 | * REVISION HISTORY (please don't use tabs!) 28 | * 29 | * 03-01-01 Marc Boucher 30 | * Ported to lwIP. 31 | * 98-07-29 Guy Lancaster , Global Election Systems Inc. 32 | * Original. 33 | * 34 | ***************************************************************************** 35 | */ 36 | 37 | #include "netif/ppp/ppp_opts.h" 38 | #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 39 | 40 | #ifndef PPPDEBUG_H 41 | #define PPPDEBUG_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Trace levels. */ 48 | #define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 49 | #define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 50 | #define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 51 | #define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 52 | #define LOG_INFO (PPP_DEBUG) 53 | #define LOG_DETAIL (PPP_DEBUG) 54 | #define LOG_DEBUG (PPP_DEBUG) 55 | 56 | #if PPP_DEBUG 57 | 58 | #define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 59 | #define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 60 | #define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 61 | #define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 62 | #define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 63 | #define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 64 | #define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 65 | #define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 66 | #define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) 67 | 68 | #else /* PPP_DEBUG */ 69 | 70 | #define MAINDEBUG(a) 71 | #define SYSDEBUG(a) 72 | #define FSMDEBUG(a) 73 | #define LCPDEBUG(a) 74 | #define IPCPDEBUG(a) 75 | #define IPV6CPDEBUG(a) 76 | #define UPAPDEBUG(a) 77 | #define CHAPDEBUG(a) 78 | #define PPPDEBUG(a, b) 79 | 80 | #endif /* PPP_DEBUG */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* PPPDEBUG_H */ 87 | 88 | #endif /* PPP_SUPPORT */ 89 | -------------------------------------------------------------------------------- /src/include/netif/slipif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * SLIP netif API 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001, Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the Institute nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Adam Dunkels 38 | * 39 | */ 40 | #ifndef LWIP_HDR_NETIF_SLIPIF_H 41 | #define LWIP_HDR_NETIF_SLIPIF_H 42 | 43 | #include "lwip/opt.h" 44 | #include "lwip/netif.h" 45 | 46 | /** Set this to 1 to start a thread that blocks reading on the serial line 47 | * (using sio_read()). 48 | */ 49 | #ifndef SLIP_USE_RX_THREAD 50 | #define SLIP_USE_RX_THREAD !NO_SYS 51 | #endif 52 | 53 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 54 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 55 | * packets on a queue, which is fed into lwIP from slipif_poll(). 56 | * If disabled, slipif_poll() polls the serial line (using sio_tryread()). 57 | */ 58 | #ifndef SLIP_RX_FROM_ISR 59 | #define SLIP_RX_FROM_ISR 0 60 | #endif 61 | 62 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 63 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 64 | * If disabled, packets will be dropped if more than one packet is received. 65 | */ 66 | #ifndef SLIP_RX_QUEUE 67 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 68 | #endif 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | err_t slipif_init(struct netif * netif); 75 | void slipif_poll(struct netif *netif); 76 | #if SLIP_RX_FROM_ISR 77 | void slipif_process_rxqueue(struct netif *netif); 78 | void slipif_received_byte(struct netif *netif, u8_t data); 79 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 80 | #endif /* SLIP_RX_FROM_ISR */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* LWIP_HDR_NETIF_SLIPIF_H */ 87 | -------------------------------------------------------------------------------- /src/include/netif/zepif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * A netif implementing the ZigBee Eencapsulation Protocol (ZEP). 5 | * This is used to tunnel 6LowPAN over UDP. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2018 Simon Goldschmidt 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Simon Goldschmidt 37 | * 38 | */ 39 | 40 | #ifndef LWIP_HDR_ZEPIF_H 41 | #define LWIP_HDR_ZEPIF_H 42 | 43 | #include "lwip/opt.h" 44 | #include "netif/lowpan6.h" 45 | 46 | #if LWIP_IPV6 && LWIP_UDP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/netif.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #define ZEPIF_DEFAULT_UDP_PORT 17754 55 | 56 | /** Pass this struct as 'state' to netif_add to control the behaviour 57 | * of this netif. If NULL is passed, default behaviour is chosen */ 58 | struct zepif_init { 59 | /** The UDP port used to ZEP frames from (0 = default) */ 60 | u16_t zep_src_udp_port; 61 | /** The UDP port used to ZEP frames to (0 = default) */ 62 | u16_t zep_dst_udp_port; 63 | /** The IP address to sed ZEP frames from (NULL = ANY) */ 64 | const ip_addr_t *zep_src_ip_addr; 65 | /** The IP address to sed ZEP frames to (NULL = BROADCAST) */ 66 | const ip_addr_t *zep_dst_ip_addr; 67 | /** If != NULL, the udp pcb is bound to this netif */ 68 | const struct netif *zep_netif; 69 | /** MAC address of the 6LowPAN device */ 70 | u8_t addr[6]; 71 | }; 72 | 73 | err_t zepif_init(struct netif *netif); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* LWIP_IPV6 && LWIP_UDP */ 80 | 81 | #endif /* LWIP_HDR_ZEPIF_H */ 82 | -------------------------------------------------------------------------------- /src/netif/ppp/eui64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.c - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #include "netif/ppp/ppp_impl.h" 42 | #include "netif/ppp/eui64.h" 43 | 44 | /* 45 | * eui64_ntoa - Make an ascii representation of an interface identifier 46 | */ 47 | char *eui64_ntoa(eui64_t e) { 48 | static char buf[20]; 49 | 50 | sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x", 51 | e.e8[0], e.e8[1], e.e8[2], e.e8[3], 52 | e.e8[4], e.e8[5], e.e8[6], e.e8[7]); 53 | return buf; 54 | } 55 | 56 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 57 | -------------------------------------------------------------------------------- /src/netif/ppp/polarssl/arc4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * An implementation of the ARCFOUR algorithm 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | /* 36 | * The ARCFOUR algorithm was publicly disclosed on 94/09. 37 | * 38 | * http://groups.google.com/group/sci.crypt/msg/10a300c9d21afca0 39 | */ 40 | 41 | #include "netif/ppp/ppp_opts.h" 42 | #if PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_ARC4 43 | 44 | #include "netif/ppp/polarssl/arc4.h" 45 | /* 46 | * ARC4 key schedule 47 | */ 48 | void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ) 49 | { 50 | int i, j, k, a; 51 | unsigned char *m; 52 | 53 | ctx->x = 0; 54 | ctx->y = 0; 55 | m = ctx->m; 56 | 57 | for( i = 0; i < 256; i++ ) 58 | m[i] = (unsigned char) i; 59 | 60 | j = k = 0; 61 | 62 | for( i = 0; i < 256; i++, k++ ) 63 | { 64 | if( k >= keylen ) k = 0; 65 | 66 | a = m[i]; 67 | j = ( j + a + key[k] ) & 0xFF; 68 | m[i] = m[j]; 69 | m[j] = (unsigned char) a; 70 | } 71 | } 72 | 73 | /* 74 | * ARC4 cipher function 75 | */ 76 | void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ) 77 | { 78 | int i, x, y, a, b; 79 | unsigned char *m; 80 | 81 | x = ctx->x; 82 | y = ctx->y; 83 | m = ctx->m; 84 | 85 | for( i = 0; i < buflen; i++ ) 86 | { 87 | x = ( x + 1 ) & 0xFF; a = m[x]; 88 | y = ( y + a ) & 0xFF; b = m[y]; 89 | 90 | m[x] = (unsigned char) b; 91 | m[y] = (unsigned char) a; 92 | 93 | buf[i] = (unsigned char) 94 | ( buf[i] ^ m[(unsigned char)( a + b )] ); 95 | } 96 | 97 | ctx->x = x; 98 | ctx->y = y; 99 | } 100 | 101 | #endif /* PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_DES */ 102 | -------------------------------------------------------------------------------- /src/netif/ppp/pppcrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1 3 | * 4 | * Extracted from chap_ms.c by James Carlson. 5 | * 6 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. The name(s) of the authors of this software must not be used to 21 | * endorse or promote products derived from this software without 22 | * prior written permission. 23 | * 24 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 25 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 26 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 27 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 28 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 29 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 30 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not necessary */ 35 | 36 | #include "netif/ppp/ppp_impl.h" 37 | 38 | #include "netif/ppp/pppcrypt.h" 39 | 40 | 41 | static u_char pppcrypt_get_7bits(u_char *input, int startBit) { 42 | unsigned int word; 43 | 44 | word = (unsigned)input[startBit / 8] << 8; 45 | word |= (unsigned)input[startBit / 8 + 1]; 46 | 47 | word >>= 15 - (startBit % 8 + 7); 48 | 49 | return word & 0xFE; 50 | } 51 | 52 | /* IN 56 bit DES key missing parity bits 53 | * OUT 64 bit DES key with parity bits added 54 | */ 55 | void pppcrypt_56_to_64_bit_key(u_char *key, u_char * des_key) { 56 | des_key[0] = pppcrypt_get_7bits(key, 0); 57 | des_key[1] = pppcrypt_get_7bits(key, 7); 58 | des_key[2] = pppcrypt_get_7bits(key, 14); 59 | des_key[3] = pppcrypt_get_7bits(key, 21); 60 | des_key[4] = pppcrypt_get_7bits(key, 28); 61 | des_key[5] = pppcrypt_get_7bits(key, 35); 62 | des_key[6] = pppcrypt_get_7bits(key, 42); 63 | des_key[7] = pppcrypt_get_7bits(key, 49); 64 | } 65 | 66 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 67 | -------------------------------------------------------------------------------- /src/ports/include/arch/bpstruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if defined(_WIN32) || defined(_WIN64) 34 | #include "../../win32/include/bpstruct.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/include/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if defined(_WIN32) || defined(_WIN64) 34 | #include "../../win32/include/cc.h" 35 | #else 36 | #include "../../unix/include/cc.h" 37 | #endif 38 | -------------------------------------------------------------------------------- /src/ports/include/arch/epstruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if defined(_WIN32) || defined(_WIN64) 34 | #include "../../win32/include/epstruct.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/include/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if defined(_WIN32) || defined(_WIN64) 34 | #include "../../win32/include/perf.h" 35 | #else 36 | #include "../../unix/include/perf.h" 37 | #endif 38 | -------------------------------------------------------------------------------- /src/ports/include/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if defined(_WIN32) || defined(_WIN64) 34 | #include "../../win32/include/sys_arch.h" 35 | #else 36 | #include "../../unix/include/sys_arch.h" 37 | #endif 38 | -------------------------------------------------------------------------------- /src/ports/include/netif/fifo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if !defined(_WIN32) && !defined(_WIN64) 34 | #include "../../unix/include/netif/fifo.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/include/netif/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if !defined(_WIN32) && !defined(_WIN64) 34 | #include "../../unix/include/netif/list.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/include/netif/pcapif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if !defined(_WIN32) && !defined(_WIN64) 34 | #include "../../unix/include/netif/pcapif.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/include/netif/sio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if !defined(_WIN32) && !defined(_WIN64) 34 | #include "../../unix/include/netif/sio.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/include/netif/tapif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if !defined(_WIN32) && !defined(_WIN64) 34 | #include "../../unix/include/netif/tapif.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ports/lib/mem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================ 3 | Name : mem.c 4 | Author : hev 5 | Copyright : Copyright (c) 2021 hev 6 | Description : Memory 7 | ============================================================================ 8 | */ 9 | 10 | #include 11 | 12 | #if defined(_WIN32) || defined(_WIN64) 13 | #define WEAK 14 | #else 15 | #define WEAK __attribute__((weak)) 16 | #endif 17 | 18 | WEAK void 19 | hev_free (void *ptr) 20 | { 21 | free (ptr); 22 | } 23 | 24 | WEAK void * 25 | hev_malloc (size_t size) 26 | { 27 | return malloc (size); 28 | } 29 | 30 | WEAK void * 31 | hev_calloc (size_t nmemb, size_t size) 32 | { 33 | return calloc (nmemb, size); 34 | } 35 | -------------------------------------------------------------------------------- /src/ports/unix/include/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_ARCH_CC_H 33 | #define LWIP_ARCH_CC_H 34 | 35 | /* see https://sourceforge.net/p/predef/wiki/OperatingSystems/ */ 36 | #if defined __ANDROID__ 37 | #define LWIP_UNIX_ANDROID 38 | #elif defined __linux__ 39 | #define LWIP_UNIX_LINUX 40 | #elif defined __APPLE__ 41 | #define LWIP_UNIX_MACH 42 | #elif defined __OpenBSD__ 43 | #define LWIP_UNIX_OPENBSD 44 | #elif defined __FreeBSD_kernel__ && __GLIBC__ 45 | #define LWIP_UNIX_KFREEBSD 46 | #elif defined __CYGWIN__ 47 | #define LWIP_UNIX_CYGWIN 48 | #elif defined __GNU__ 49 | #define LWIP_UNIX_HURD 50 | #endif 51 | 52 | #define LWIP_TIMEVAL_PRIVATE 0 53 | #include 54 | 55 | #define LWIP_ERRNO_INCLUDE 56 | 57 | #if defined(LWIP_UNIX_LINUX) || defined(LWIP_UNIX_HURD) || defined(LWIP_UNIX_KFREEBSD) 58 | #define LWIP_ERRNO_STDINCLUDE 1 59 | #endif 60 | 61 | extern unsigned int lwip_port_rand(void); 62 | #define LWIP_RAND() (lwip_port_rand()) 63 | 64 | /* different handling for unit test, normally not needed */ 65 | #ifdef LWIP_NOASSERT_ON_ERROR 66 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 67 | handler;}} while(0) 68 | #endif 69 | 70 | #if defined(LWIP_UNIX_ANDROID) && defined(FD_SET) && !defined(FD_SET_DEFINED) 71 | typedef __kernel_fd_set fd_set; 72 | #endif 73 | 74 | #if defined(LWIP_UNIX_MACH) 75 | /* sys/types.h and signal.h bring in Darwin byte order macros. pull the 76 | header here and disable LwIP's version so that apps still can get 77 | the macros via LwIP headers and use system headers */ 78 | #include 79 | #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 80 | #endif 81 | 82 | struct sio_status_s; 83 | typedef struct sio_status_s sio_status_t; 84 | #define sio_fd_t sio_status_t* 85 | #define __sio_fd_t_defined 86 | 87 | typedef unsigned int sys_prot_t; 88 | 89 | #endif /* LWIP_ARCH_CC_H */ 90 | -------------------------------------------------------------------------------- /src/ports/unix/include/netif/fifo.h: -------------------------------------------------------------------------------- 1 | #ifndef FIFO_H 2 | #define FIFO_H 3 | 4 | #include "lwip/sys.h" 5 | 6 | /** How many bytes in fifo */ 7 | #define FIFOSIZE 2048 8 | 9 | /** fifo data structure, this one is passed to all fifo functions */ 10 | typedef struct fifo_t { 11 | u8_t data[FIFOSIZE+10]; /* data segment, +10 is a hack probably not needed.. FIXME! */ 12 | int dataslot; /* index to next char to be read */ 13 | int emptyslot; /* index to next empty slot */ 14 | int len; /* len probably not needed, may be calculated from dataslot and emptyslot in conjunction with FIFOSIZE */ 15 | 16 | sys_sem_t sem; /* semaphore protecting simultaneous data manipulation */ 17 | sys_sem_t getSem; /* sepaphore used to signal new data if getWaiting is set */ 18 | u8_t getWaiting; /* flag used to indicate that fifoget is waiting for data. fifoput is supposed to clear */ 19 | /* this flag prior to signaling the getSem semaphore */ 20 | } fifo_t; 21 | 22 | 23 | /** 24 | * Get a character from fifo 25 | * Blocking call. 26 | * @param fifo pointer to fifo data structure 27 | * @return character read from fifo 28 | */ 29 | u8_t fifoGet(fifo_t * fifo); 30 | 31 | /** 32 | * Get a character from fifo 33 | * Non blocking call. 34 | * @param fifo pointer to fifo data structure 35 | * @return character read from fifo, or < zero if non was available 36 | */ 37 | s16_t fifoGetNonBlock(fifo_t * fifo); 38 | 39 | /** 40 | * fifoput is called by the signalhandler when new data has arrived (or some other event is indicated) 41 | * fifoput reads directly from the serialport and is thus highly dependent on unix arch at this moment 42 | * @param fifo pointer to fifo data structure 43 | * @param fd unix file descriptor 44 | */ 45 | void fifoPut(fifo_t * fifo, int fd); 46 | 47 | /** 48 | * fifoinit initiate fifo 49 | * @param fifo pointer to fifo data structure, allocated by the user 50 | */ 51 | void fifoInit(fifo_t * fifo); 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /src/ports/unix/include/netif/list.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LWIP_LIST_H 3 | #define LWIP_LIST_H 4 | 5 | struct elem; 6 | 7 | struct list { 8 | struct elem *first, *last; 9 | int size, elems; 10 | }; 11 | 12 | struct elem { 13 | struct elem *next; 14 | void *data; 15 | }; 16 | 17 | struct list *list_new(int size); 18 | int list_push(struct list *list, void *data); 19 | void *list_pop(struct list *list); 20 | void *list_first(struct list *list); 21 | int list_elems(struct list *list); 22 | void list_delete(struct list *list); 23 | int list_remove(struct list *list, void *elem); 24 | void list_map(struct list *list, void (* func)(void *arg)); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/ports/unix/include/netif/pcapif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_PCAPIF_H 33 | #define LWIP_PCAPIF_H 34 | 35 | #include "lwip/netif.h" 36 | 37 | err_t pcapif_init(struct netif *netif); 38 | 39 | #endif /* LWIP_PCAPIF_H */ 40 | -------------------------------------------------------------------------------- /src/ports/unix/include/netif/sio.h: -------------------------------------------------------------------------------- 1 | #ifndef SIO_UNIX_H 2 | #define SIO_UNIX_H 3 | 4 | #include "lwip/sys.h" 5 | #include "lwip/netif.h" 6 | #include "netif/fifo.h" 7 | /*#include "netif/pppif.h"*/ 8 | 9 | struct sio_status_s { 10 | int fd; 11 | fifo_t myfifo; 12 | }; 13 | 14 | /* BAUDRATE is defined in sio.c as it is implementation specific */ 15 | /** Baudrates */ 16 | typedef enum sioBaudrates { 17 | SIO_BAUD_9600, 18 | SIO_BAUD_19200, 19 | SIO_BAUD_38400, 20 | SIO_BAUD_57600, 21 | SIO_BAUD_115200 22 | } sioBaudrates; 23 | 24 | /** 25 | * Poll for a new character from incoming data stream 26 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 27 | * @return char read from input stream, or < 0 if no char was available 28 | */ 29 | s16_t sio_poll(sio_status_t * siostat); 30 | 31 | /** 32 | * Parse incoming characters until a string str is received, blocking call 33 | * @param str zero terminated string to expect 34 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 35 | */ 36 | void sio_expect_string(u8_t *str, sio_status_t * siostat); 37 | 38 | /** 39 | * Write a char to output data stream 40 | * @param str pointer to a zero terminated string 41 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 42 | */ 43 | void sio_send_string(u8_t *str, sio_status_t * siostat); 44 | 45 | /** 46 | * Flush outbuffer (send everything in buffer now), useful if some layer below is 47 | * holding on to data, waitng to fill a buffer 48 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 49 | */ 50 | void sio_flush( sio_status_t * siostat ); 51 | 52 | /** 53 | * Change baudrate of port, may close and reopen port 54 | * @param baud new baudrate 55 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 56 | */ 57 | void sio_change_baud( sioBaudrates baud, sio_status_t * siostat ); 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /src/ports/unix/include/netif/tapif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_TAPIF_H 33 | #define LWIP_TAPIF_H 34 | 35 | #include "lwip/netif.h" 36 | 37 | err_t tapif_init(struct netif *netif); 38 | void tapif_poll(struct netif *netif); 39 | #if NO_SYS 40 | int tapif_select(struct netif *netif); 41 | #endif /* NO_SYS */ 42 | 43 | #endif /* LWIP_TAPIF_H */ 44 | -------------------------------------------------------------------------------- /src/ports/unix/include/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_ARCH_PERF_H 33 | #define LWIP_ARCH_PERF_H 34 | 35 | #include 36 | 37 | #ifdef PERF 38 | #define PERF_START { \ 39 | unsigned long __c1l, __c1h, __c2l, __c2h; \ 40 | __asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h)) 41 | #define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \ 42 | perf_print(__c1l, __c1h, __c2l, __c2h, x);} 43 | 44 | /*#define PERF_START do { \ 45 | struct tms __perf_start, __perf_end; \ 46 | times(&__perf_start) 47 | #define PERF_STOP(x) times(&__perf_end); \ 48 | perf_print_times(&__perf_start, &__perf_end, x);\ 49 | } while(0)*/ 50 | #else /* PERF */ 51 | #define PERF_START /* null definition */ 52 | #define PERF_STOP(x) /* null definition */ 53 | #endif /* PERF */ 54 | 55 | void perf_print(unsigned long c1l, unsigned long c1h, 56 | unsigned long c2l, unsigned long c2h, 57 | char *key); 58 | 59 | void perf_print_times(struct tms *start, struct tms *end, char *key); 60 | 61 | void perf_init(char *fname); 62 | 63 | #endif /* LWIP_ARCH_PERF_H */ 64 | -------------------------------------------------------------------------------- /src/ports/unix/include/sys_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_ARCH_SYS_ARCH_H 33 | #define LWIP_ARCH_SYS_ARCH_H 34 | 35 | #define SYS_MBOX_NULL NULL 36 | #define SYS_SEM_NULL NULL 37 | 38 | /*typedef u32_t sys_prot_t;*/ 39 | 40 | struct sys_sem; 41 | typedef struct sys_sem * sys_sem_t; 42 | #define sys_sem_valid(sem) (((sem) != NULL) && (*(sem) != NULL)) 43 | #define sys_sem_valid_val(sem) ((sem) != NULL) 44 | #define sys_sem_set_invalid(sem) do { if((sem) != NULL) { *(sem) = NULL; }}while(0) 45 | #define sys_sem_set_invalid_val(sem) do { (sem) = NULL; }while(0) 46 | 47 | struct sys_mutex; 48 | typedef struct sys_mutex * sys_mutex_t; 49 | #define sys_mutex_valid(mutex) sys_sem_valid(mutex) 50 | #define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) 51 | 52 | struct sys_mbox; 53 | typedef struct sys_mbox * sys_mbox_t; 54 | #define sys_mbox_valid(mbox) sys_sem_valid(mbox) 55 | #define sys_mbox_valid_val(mbox) sys_sem_valid_val(mbox) 56 | #define sys_mbox_set_invalid(mbox) sys_sem_set_invalid(mbox) 57 | #define sys_mbox_set_invalid_val(mbox) sys_sem_set_invalid_val(mbox) 58 | 59 | struct sys_thread; 60 | typedef struct sys_thread * sys_thread_t; 61 | 62 | #if LWIP_NETCONN_SEM_PER_THREAD 63 | sys_sem_t* sys_arch_netconn_sem_get(void); 64 | void sys_arch_netconn_sem_alloc(void); 65 | void sys_arch_netconn_sem_free(void); 66 | #define LWIP_NETCONN_THREAD_SEM_GET() sys_arch_netconn_sem_get() 67 | #define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_arch_netconn_sem_alloc() 68 | #define LWIP_NETCONN_THREAD_SEM_FREE() sys_arch_netconn_sem_free() 69 | #endif /* #if LWIP_NETCONN_SEM_PER_THREAD */ 70 | 71 | #define LWIP_EXAMPLE_APP_ABORT() lwip_unix_keypressed() 72 | int lwip_unix_keypressed(void); 73 | 74 | /* 75 | --------------------------------------- 76 | ---------- Threading options ---------- 77 | --------------------------------------- 78 | */ 79 | 80 | void sys_mark_tcpip_thread(void); 81 | #define LWIP_MARK_TCPIP_THREAD() sys_mark_tcpip_thread() 82 | 83 | #if LWIP_TCPIP_CORE_LOCKING 84 | void sys_lock_tcpip_core(void); 85 | #define LOCK_TCPIP_CORE() sys_lock_tcpip_core() 86 | void sys_unlock_tcpip_core(void); 87 | #define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core() 88 | #endif 89 | 90 | #endif /* LWIP_ARCH_SYS_ARCH_H */ 91 | -------------------------------------------------------------------------------- /src/ports/unix/lib/perf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #if !defined(_WIN32) && !defined(_WIN64) 34 | 35 | #include "arch/perf.h" 36 | 37 | #include 38 | 39 | static FILE *f; 40 | 41 | void 42 | perf_print(unsigned long c1l, unsigned long c1h, 43 | unsigned long c2l, unsigned long c2h, 44 | char *key) 45 | { 46 | unsigned long sub_ms, sub_ls; 47 | 48 | sub_ms = c2h - c1h; 49 | sub_ls = c2l - c1l; 50 | if (c2l < c1l) sub_ms--; 51 | fprintf(f, "%s: %.8lu%.8lu\n", key, sub_ms, sub_ls); 52 | fflush(NULL); 53 | } 54 | 55 | void 56 | perf_print_times(struct tms *start, struct tms *end, char *key) 57 | { 58 | fprintf(f, "%s: %lu\n", key, end->tms_stime - start->tms_stime); 59 | fflush(NULL); 60 | } 61 | 62 | void 63 | perf_init(char *fname) 64 | { 65 | f = fopen(fname, "w"); 66 | } 67 | 68 | #endif /* !defined(_WIN32) && !defined(_WIN64) */ 69 | -------------------------------------------------------------------------------- /src/ports/unix/netif/fifo.c: -------------------------------------------------------------------------------- 1 | /* Author: Magnus Ivarsson */ 2 | 3 | /* ---------------------------------------------- */ 4 | /* --- fifo 4 unix ------------------------------ */ 5 | /* ---------------------------------------------- */ 6 | 7 | #if !defined(_WIN32) && !defined(_WIN64) 8 | 9 | #include "lwip/err.h" 10 | #include "netif/fifo.h" 11 | #include "lwip/debug.h" 12 | #include "lwip/def.h" 13 | #include "lwip/sys.h" 14 | #include "lwip/arch.h" 15 | #include 16 | 17 | #ifndef TRUE 18 | #define TRUE 1 19 | #endif 20 | #ifndef FALSE 21 | #define FALSE 0 22 | #endif 23 | 24 | #ifndef SIO_FIFO_DEBUG 25 | #define SIO_FIFO_DEBUG LWIP_DBG_OFF 26 | #endif 27 | 28 | u8_t fifoGet(fifo_t * fifo) 29 | { 30 | u8_t c; 31 | 32 | sys_sem_wait(&fifo->sem); /* enter critical section */ 33 | 34 | if (fifo->dataslot == fifo->emptyslot) 35 | { 36 | fifo->getWaiting = TRUE; /* tell putFifo to signal us when data is available */ 37 | sys_sem_signal(&fifo->sem); /* leave critical section (allow input from serial port..) */ 38 | sys_sem_wait(&fifo->getSem); /* wait 4 data */ 39 | sys_sem_wait(&fifo->sem); /* reenter critical section */ 40 | } 41 | 42 | c = fifo->data[fifo->dataslot++]; 43 | fifo->len--; 44 | 45 | if (fifo->dataslot == FIFOSIZE) 46 | { 47 | fifo->dataslot = 0; 48 | } 49 | sys_sem_signal(&fifo->sem); /* leave critical section */ 50 | return c; 51 | } 52 | 53 | 54 | s16_t fifoGetNonBlock(fifo_t * fifo) 55 | { 56 | u16_t c; 57 | 58 | sys_sem_wait(&fifo->sem); /* enter critical section */ 59 | 60 | if (fifo->dataslot == fifo->emptyslot) 61 | { 62 | /* empty fifo */ 63 | c = -1; 64 | } 65 | else 66 | { 67 | c = fifo->data[fifo->dataslot++]; 68 | fifo->len--; 69 | 70 | if (fifo->dataslot == FIFOSIZE) 71 | { 72 | fifo->dataslot = 0; 73 | } 74 | } 75 | sys_sem_signal(&fifo->sem); /* leave critical section */ 76 | return c; 77 | } 78 | 79 | 80 | void fifoPut(fifo_t * fifo, int fd) 81 | { 82 | /* FIXME: mutex around struct data.. */ 83 | int cnt=0; 84 | 85 | sys_sem_wait(&fifo->sem ); /* enter critical */ 86 | 87 | LWIP_DEBUGF( SIO_FIFO_DEBUG,("fifoput: len%d dat%d empt%d --> ", fifo->len, fifo->dataslot, fifo->emptyslot ) ); 88 | 89 | if ( fifo->emptyslot < fifo->dataslot ) 90 | { 91 | cnt = read( fd, &fifo->data[fifo->emptyslot], fifo->dataslot - fifo->emptyslot ); 92 | } 93 | else 94 | { 95 | cnt = read( fd, &fifo->data[fifo->emptyslot], FIFOSIZE-fifo->emptyslot ); 96 | } 97 | fifo->emptyslot += cnt; 98 | fifo->len += cnt; 99 | 100 | LWIP_DEBUGF( SIO_FIFO_DEBUG,("len%d dat%d empt%d\n", fifo->len, fifo->dataslot, fifo->emptyslot ) ); 101 | 102 | if ( fifo->len > FIFOSIZE ) 103 | { 104 | printf( "ERROR: fifo overrun detected len=%d, flushing\n", fifo->len ); 105 | fifo->dataslot = 0; 106 | fifo->emptyslot = 0; 107 | fifo->len = 0; 108 | } 109 | 110 | if ( fifo->emptyslot == FIFOSIZE ) 111 | { 112 | fifo->emptyslot = 0; 113 | LWIP_DEBUGF( SIO_FIFO_DEBUG, ("(WRAP) ") ); 114 | 115 | sys_sem_signal(&fifo->sem ); /* leave critical */ 116 | fifoPut( fifo, fd ); 117 | return; 118 | } 119 | if ( fifo->getWaiting ) 120 | { 121 | fifo->getWaiting = FALSE; 122 | sys_sem_signal(&fifo->getSem ); 123 | } 124 | 125 | sys_sem_signal(&fifo->sem ); /* leave critical */ 126 | return; 127 | } 128 | 129 | 130 | void fifoInit(fifo_t * fifo) 131 | { 132 | fifo->dataslot = 0; 133 | fifo->emptyslot = 0; 134 | fifo->len = 0; 135 | if(sys_sem_new(&fifo->sem, 1) != ERR_OK) { /* critical section 1=free to enter */ 136 | LWIP_ASSERT("Failed to create semaphore", 0); 137 | } 138 | if(sys_sem_new(&fifo->getSem, 0) != ERR_OK) { /* 0 = no one waiting */ 139 | LWIP_ASSERT("Failed to create semaphore", 0); 140 | } 141 | fifo->getWaiting = FALSE; 142 | } 143 | 144 | #endif /* !defined(_WIN32) && !defined(_WIN64) */ 145 | -------------------------------------------------------------------------------- /src/ports/win32/include/bpstruct.h: -------------------------------------------------------------------------------- 1 | #pragma pack(push,1) 2 | -------------------------------------------------------------------------------- /src/ports/win32/include/epstruct.h: -------------------------------------------------------------------------------- 1 | #pragma pack(pop) 2 | -------------------------------------------------------------------------------- /src/ports/win32/include/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef LWIP_PERF_H 35 | #define LWIP_PERF_H 36 | 37 | #define PERF_START /* null definition */ 38 | #define PERF_STOP(x) /* null definition */ 39 | 40 | #endif /* LWIP_PERF_H */ 41 | -------------------------------------------------------------------------------- /src/ports/win32/include/sys_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_ARCH_SYS_ARCH_H 33 | #define LWIP_ARCH_SYS_ARCH_H 34 | 35 | /* HANDLE is used for sys_sem_t but we won't include windows.h */ 36 | struct _sys_sem { 37 | void *sem; 38 | }; 39 | typedef struct _sys_sem sys_sem_t; 40 | #define sys_sem_valid_val(sema) (((sema).sem != NULL) && ((sema).sem != (void*)-1)) 41 | #define sys_sem_valid(sema) (((sema) != NULL) && sys_sem_valid_val(*(sema))) 42 | #define sys_sem_set_invalid(sema) ((sema)->sem = NULL) 43 | 44 | /* HANDLE is used for sys_mutex_t but we won't include windows.h */ 45 | struct _sys_mut { 46 | void *mut; 47 | }; 48 | typedef struct _sys_mut sys_mutex_t; 49 | #define sys_mutex_valid_val(mutex) (((mutex).mut != NULL) && ((mutex).mut != (void*)-1)) 50 | #define sys_mutex_valid(mutex) (((mutex) != NULL) && sys_mutex_valid_val(*(mutex))) 51 | #define sys_mutex_set_invalid(mutex) ((mutex)->mut = NULL) 52 | 53 | #ifndef MAX_QUEUE_ENTRIES 54 | #define MAX_QUEUE_ENTRIES 100 55 | #endif 56 | struct lwip_mbox { 57 | void* sem; 58 | void* q_mem[MAX_QUEUE_ENTRIES]; 59 | u32_t head, tail; 60 | }; 61 | typedef struct lwip_mbox sys_mbox_t; 62 | #define SYS_MBOX_NULL NULL 63 | #define sys_mbox_valid_val(mbox) (((mbox).sem != NULL) && ((mbox).sem != (void*)-1)) 64 | #define sys_mbox_valid(mbox) ((mbox != NULL) && sys_mbox_valid_val(*(mbox))) 65 | #define sys_mbox_set_invalid(mbox) ((mbox)->sem = NULL) 66 | 67 | /* DWORD (thread id) is used for sys_thread_t but we won't include windows.h */ 68 | typedef u32_t sys_thread_t; 69 | 70 | sys_sem_t* sys_arch_netconn_sem_get(void); 71 | void sys_arch_netconn_sem_alloc(void); 72 | void sys_arch_netconn_sem_free(void); 73 | #define LWIP_NETCONN_THREAD_SEM_GET() sys_arch_netconn_sem_get() 74 | #define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_arch_netconn_sem_alloc() 75 | #define LWIP_NETCONN_THREAD_SEM_FREE() sys_arch_netconn_sem_free() 76 | 77 | #define LWIP_EXAMPLE_APP_ABORT() lwip_win32_keypressed() 78 | int lwip_win32_keypressed(void); 79 | 80 | /* Threading options */ 81 | void sys_mark_tcpip_thread(void); 82 | #define LWIP_MARK_TCPIP_THREAD() sys_mark_tcpip_thread() 83 | 84 | #if LWIP_TCPIP_CORE_LOCKING 85 | void sys_lock_tcpip_core(void); 86 | #define LOCK_TCPIP_CORE() sys_lock_tcpip_core() 87 | void sys_unlock_tcpip_core(void); 88 | #define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core() 89 | #endif 90 | 91 | #endif /* LWIP_ARCH_SYS_ARCH_H */ 92 | --------------------------------------------------------------------------------