├── src ├── core │ ├── ipv6 │ │ ├── README │ │ ├── dhcp6.c │ │ └── inet6.c │ ├── sys.c │ └── def.c ├── FILES ├── contrib │ └── ports │ │ ├── unix │ │ ├── include │ │ │ ├── netif │ │ │ │ ├── list.h │ │ │ │ ├── tapif.h │ │ │ │ ├── pcapif.h │ │ │ │ ├── tunif.h │ │ │ │ ├── dropif.h │ │ │ │ ├── fifo.h │ │ │ │ ├── tcpdump.h │ │ │ │ ├── unixif.h │ │ │ │ ├── delif.h │ │ │ │ └── sio.h │ │ │ └── arch │ │ │ │ ├── sys_arch.h │ │ │ │ ├── perf.h │ │ │ │ └── cc.h │ │ ├── perf.c │ │ ├── lwip_chksum.c │ │ └── netif │ │ │ ├── fifo.c │ │ │ └── list.c │ │ └── ucos-ii │ │ ├── doc │ │ └── README.txt │ │ ├── include │ │ └── arch │ │ │ ├── big │ │ │ └── cpu.h │ │ │ ├── little │ │ │ └── cpu.h │ │ │ ├── perf.h │ │ │ ├── sys_arch.h │ │ │ ├── sys_arch_opts.h │ │ │ └── cc.h │ │ └── lib.c ├── netif │ ├── FILES │ └── ppp │ │ ├── readme.txt │ │ ├── pppdebug.h │ │ ├── magic.h │ │ ├── md5.h │ │ ├── chpms.h │ │ ├── magic.c │ │ ├── randm.h │ │ └── auth.h ├── include │ ├── posix │ │ ├── netdb.h │ │ └── sys │ │ │ └── socket.h │ ├── ipv6 │ │ └── lwip │ │ │ ├── dhcp6.h │ │ │ ├── ethip6.h │ │ │ ├── ip6_frag.h │ │ │ ├── inet6.h │ │ │ └── mld6.h │ ├── lwip │ │ ├── init.h │ │ ├── err.h │ │ ├── timers.h │ │ ├── def.h │ │ ├── memp.h │ │ ├── snmp_asn1.h │ │ ├── debug.h │ │ ├── mem.h │ │ ├── sio.h │ │ ├── netifapi.h │ │ ├── inet_chksum.h │ │ └── netbuf.h │ ├── netif │ │ └── slipif.h │ └── ipv4 │ │ └── lwip │ │ ├── ip_frag.h │ │ ├── igmp.h │ │ ├── icmp.h │ │ └── inet.h └── api │ └── err.c ├── CHANGELOG ├── .gitattributes ├── FILES ├── test └── unit │ ├── tcp │ ├── test_tcp.h │ ├── test_tcp_oos.h │ └── tcp_helper.h │ ├── udp │ ├── test_udp.h │ └── test_udp.c │ ├── core │ ├── test_mem.h │ ├── test_pbuf.h │ ├── test_mem.c │ └── test_pbuf.c │ ├── dhcp │ └── test_dhcp.h │ ├── etharp │ └── test_etharp.h │ ├── lwip_unittests.c │ ├── lwip_check.h │ └── lwipopts.h ├── .travis.yml ├── doc ├── FILES └── contrib.txt ├── COPYING └── README.md /src/core/ipv6/README: -------------------------------------------------------------------------------- 1 | IPv6 support in lwIP is very experimental. 2 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvra/lwip_ucos2/HEAD/CHANGELOG -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # These files are text and should be normalized 2 | *.txt text 3 | *.c text 4 | *.h text 5 | -------------------------------------------------------------------------------- /FILES: -------------------------------------------------------------------------------- 1 | src/ - The source code for the lwIP TCP/IP stack. 2 | doc/ - The documentation for lwIP. 3 | 4 | See also the FILES file in each subdirectory. 5 | -------------------------------------------------------------------------------- /test/unit/tcp/test_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_TCP_H__ 2 | #define __TEST_TCP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/udp/test_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_UDP_H__ 2 | #define __TEST_UDP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* udp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/core/test_mem.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_MEM_H__ 2 | #define __TEST_MEM_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *mem_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/core/test_pbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_PBUF_H__ 2 | #define __TEST_PBUF_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *pbuf_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/dhcp/test_dhcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_DHCP_H__ 2 | #define __TEST_DHCP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* dhcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/etharp/test_etharp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_ETHARP_H__ 2 | #define __TEST_ETHARP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* etharp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/tcp/test_tcp_oos.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_TCP_OOS_H__ 2 | #define __TEST_TCP_OOS_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_oos_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - gcc 4 | - clang 5 | 6 | install: 7 | - git clone https://github.com/antoinealb/lwip_test.git ../lwip_test 8 | 9 | before_script: 10 | - cd ../lwip_test 11 | - mkdir build 12 | - cd build 13 | - cmake .. 14 | 15 | script: make; cd ..; ./run_tests.sh 16 | -------------------------------------------------------------------------------- /doc/FILES: -------------------------------------------------------------------------------- 1 | savannah.txt - How to obtain the current development source code. 2 | contrib.txt - How to contribute to lwIP as a developer. 3 | rawapi.txt - The documentation for the core API of lwIP. 4 | Also provides an overview about the other APIs and multithreading. 5 | snmp_agent.txt - The documentation for the lwIP SNMP agent. 6 | sys_arch.txt - The documentation for a system abstraction layer of lwIP. 7 | -------------------------------------------------------------------------------- /src/FILES: -------------------------------------------------------------------------------- 1 | api/ - The code for the high-level wrapper API. Not needed if 2 | you use the lowel-level call-back/raw API. 3 | 4 | core/ - The core of the TPC/IP stack; protocol implementations, 5 | memory and buffer management, and the low-level raw API. 6 | 7 | include/ - lwIP include files. 8 | 9 | netif/ - Generic network interface device drivers are kept here, 10 | as well as the ARP module. 11 | 12 | For more information on the various subdirectories, check the FILES 13 | file in each directory. 14 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/include/netif/list.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __LIST_H__ 3 | #define __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 | -------------------------------------------------------------------------------- /test/unit/lwip_unittests.c: -------------------------------------------------------------------------------- 1 | #include "lwip_check.h" 2 | 3 | #include "udp/test_udp.h" 4 | #include "tcp/test_tcp.h" 5 | #include "tcp/test_tcp_oos.h" 6 | #include "core/test_mem.h" 7 | #include "core/test_pbuf.h" 8 | #include "etharp/test_etharp.h" 9 | #include "dhcp/test_dhcp.h" 10 | 11 | #include "lwip/init.h" 12 | 13 | 14 | int main() 15 | { 16 | int number_failed; 17 | SRunner *sr; 18 | size_t i; 19 | suite_getter_fn* suites[] = { 20 | udp_suite, 21 | tcp_suite, 22 | tcp_oos_suite, 23 | mem_suite, 24 | pbuf_suite, 25 | etharp_suite, 26 | dhcp_suite 27 | }; 28 | size_t num = sizeof(suites)/sizeof(void*); 29 | LWIP_ASSERT("No suites defined", num > 0); 30 | 31 | lwip_init(); 32 | 33 | sr = srunner_create((suites[0])()); 34 | for(i = 1; i < num; i++) { 35 | srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); 36 | } 37 | 38 | #ifdef LWIP_UNITTESTS_NOFORK 39 | srunner_set_fork_status(sr, CK_NOFORK); 40 | #endif 41 | #ifdef LWIP_UNITTESTS_FORK 42 | srunner_set_fork_status(sr, CK_FORK); 43 | #endif 44 | 45 | srunner_run_all(sr, CK_NORMAL); 46 | number_failed = srunner_ntests_failed(sr); 47 | srunner_free(sr); 48 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 49 | } 50 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/doc/README.txt: -------------------------------------------------------------------------------- 1 | LwIP uCOS-II Port 2 | 3 | Date : 12.01.2005 4 | Version : 1.1 5 | LwIP source : From CVS 6 | 7 | put together by Michael Anburaj 8 | Homepage: http://geocities.com/michaelanburaj/ 9 | e-mail : embeddedeng@yahoo.com 10 | 11 | 12 | Installation : UNZIP to desired folder (\contrib\ports\ is recommended) 13 | 14 | This port was tested on following setups: 15 | 16 | MIPS Atlas 17 | ---------- 18 | Processor : MIPS 4Kc/Atlas 19 | uCOS-II : ver 2.61 20 | LwIP : From CVS repository 21 | tool-chain: GNU (mipsisa32-elf) 22 | Interfaces: Ethernet (SAA9730, RLTK8139) & WiFi (Prism II chipset) 23 | 24 | LPC2106 25 | ------- 26 | Processor : ARM7TDMI-S/LPC2106 IAR Kickstart board 27 | uCOS-II : ver 2.61 28 | LwIP : From CVS repository 29 | tool-chain: GNU (arm-elf) 30 | Interfaces: Ethernet (CS8900A) 31 | 32 | 33 | Important!!! 34 | 35 | This is a generic port for uC/OS-II. Hence it should run without or minmal change on any processor platform running uC/OS-II. 36 | 37 | This port can be modified very easily to make it work on other RTOSes too. Please feel free to get in touch with me for further help. 38 | 39 | 40 | Cheers, 41 | Michael Anburaj. -------------------------------------------------------------------------------- /src/netif/FILES: -------------------------------------------------------------------------------- 1 | This directory contains generic network interface device drivers that 2 | do not contain any hardware or architecture specific code. The files 3 | are: 4 | 5 | etharp.c 6 | Implements the ARP (Address Resolution Protocol) over 7 | Ethernet. The code in this file should be used together with 8 | Ethernet device drivers. Note that this module has been 9 | largely made Ethernet independent so you should be able to 10 | adapt this for other link layers (such as Firewire). 11 | 12 | ethernetif.c 13 | An example of how an Ethernet device driver could look. This 14 | file can be used as a "skeleton" for developing new Ethernet 15 | network device drivers. It uses the etharp.c ARP code. 16 | 17 | loopif.c 18 | A "loopback" network interface driver. It requires configuration 19 | through the define LWIP_LOOPIF_MULTITHREADING (see opt.h). 20 | 21 | slipif.c 22 | A generic implementation of the SLIP (Serial Line IP) 23 | protocol. It requires a sio (serial I/O) module to work. 24 | 25 | ppp/ Point-to-Point Protocol stack 26 | The PPP stack has been ported from ucip (http://ucip.sourceforge.net). 27 | It matches quite well to pppd 2.3.1 (http://ppp.samba.org), although 28 | compared to that, it has some modifications for embedded systems and 29 | the source code has been reordered a bit. -------------------------------------------------------------------------------- /src/netif/ppp/readme.txt: -------------------------------------------------------------------------------- 1 | About the PPP code: 2 | 3 | The PPP code is not our "own" code - we just copied it from pppd (http://ppp.samba.org/) and adapted it to lwIP. 4 | Unfortunately, not many here know their way around it too well. Back in 2009, we took the effort to see which 5 | version of pppd our code relates to and we're pretty much on 2.3.11 with some bugs from 2.4.x backported. 6 | 7 | Aside from simple code adaptions, there are some files that are different, however: 8 | - chpms.c/.h are named chap_ms.c/.h in the original pppd 2.3.11 sources 9 | - pap.c/.h are named upap.c/.h in the original pppd 2.3.11 sources 10 | - randm.c is a random generator not included in the original pppd 11 | - magic.c does not use the C library's random functions, but uses randm.c instead 12 | - vj.c/.h is an implementation of the Van Jacobson header compression algorithm adapted to lwIP pbufs, 13 | probably copied from one of the vjcompress.c files from pppd. 14 | - ppp.c, ppp.h and ppp_impl.h contain the adaption from pppd to lwIP. This is the "OS"-dependent part like there 15 | is an implementation for linux, xBSD etc. in the pppd sources. 16 | - ppp_oe.c is Marc Boucher's implementation based on NetBSD's if_pppoe.c 17 | 18 | There is of course potential for bugs in it, but when analyzing of reporting bugs, it is strongly encouraged to 19 | compare the code in question to pppd 2.3.11 (our basis) and newer versions (perhaps it's already fixed?) and to 20 | share this knowledge with us when reporting a bug. 21 | 22 | -------------------------------------------------------------------------------- /test/unit/lwip_check.h: -------------------------------------------------------------------------------- 1 | #ifndef __LWIP_CHECK_H__ 2 | #define __LWIP_CHECK_H__ 3 | 4 | /* Common header file for lwIP unit tests using the check framework */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define FAIL_RET() do { fail(); return; } while(0) 11 | #define EXPECT(x) fail_unless(x) 12 | #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0) 13 | #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) 14 | #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) 15 | 16 | typedef struct { 17 | TFun func; 18 | const char *name; 19 | } testfunc; 20 | 21 | #define TESTFUNC(x) {(x), "" # x "" } 22 | 23 | /* Modified function from check.h, supplying function name */ 24 | #define tcase_add_named_test(tc,tf) \ 25 | _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1) 26 | 27 | /** typedef for a function returning a test suite */ 28 | typedef Suite* (suite_getter_fn)(void); 29 | 30 | /** Create a test suite */ 31 | static Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown) 32 | { 33 | size_t i; 34 | Suite *s = suite_create(name); 35 | 36 | for(i = 0; i < num_tests; i++) { 37 | TCase *tc_core = tcase_create(name); 38 | if ((setup != NULL) || (teardown != NULL)) { 39 | tcase_add_checked_fixture(tc_core, setup, teardown); 40 | } 41 | tcase_add_named_test(tc_core, tests[i]); 42 | suite_add_tcase(s, tc_core); 43 | } 44 | return s; 45 | } 46 | 47 | #endif /* __LWIP_CHECK_H__ */ 48 | -------------------------------------------------------------------------------- /test/unit/udp/test_udp.c: -------------------------------------------------------------------------------- 1 | #include "test_udp.h" 2 | 3 | #include "lwip/udp.h" 4 | #include "lwip/stats.h" 5 | 6 | #if !LWIP_STATS || !UDP_STATS || !MEMP_STATS 7 | #error "This tests needs UDP- and MEMP-statistics enabled" 8 | #endif 9 | 10 | /* Helper functions */ 11 | static void 12 | udp_remove_all(void) 13 | { 14 | struct udp_pcb *pcb = udp_pcbs; 15 | struct udp_pcb *pcb2; 16 | 17 | while(pcb != NULL) { 18 | pcb2 = pcb; 19 | pcb = pcb->next; 20 | udp_remove(pcb2); 21 | } 22 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); 23 | } 24 | 25 | /* Setups/teardown functions */ 26 | 27 | static void 28 | udp_setup(void) 29 | { 30 | udp_remove_all(); 31 | } 32 | 33 | static void 34 | udp_teardown(void) 35 | { 36 | udp_remove_all(); 37 | } 38 | 39 | 40 | /* Test functions */ 41 | 42 | START_TEST(test_udp_new_remove) 43 | { 44 | struct udp_pcb* pcb; 45 | LWIP_UNUSED_ARG(_i); 46 | 47 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); 48 | 49 | pcb = udp_new(); 50 | fail_unless(pcb != NULL); 51 | if (pcb != NULL) { 52 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 1); 53 | udp_remove(pcb); 54 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); 55 | } 56 | } 57 | END_TEST 58 | 59 | 60 | /** Create the suite including all tests for this module */ 61 | Suite * 62 | udp_suite(void) 63 | { 64 | testfunc tests[] = { 65 | TESTFUNC(test_udp_new_remove), 66 | }; 67 | return create_suite("UDP", tests, sizeof(tests)/sizeof(testfunc), udp_setup, udp_teardown); 68 | } 69 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/include/arch/big/cpu.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * PROJECT : uCOS_LWIP (uC/OS LwIP port) * 4 | * * 5 | * MODULE : CPU.h * 6 | * * 7 | * AUTHOR : Michael Anburaj * 8 | * URL : http://geocities.com/michaelanburaj/ * 9 | * EMAIL: michaelanburaj@hotmail.com * 10 | * * 11 | * PROCESSOR : Any * 12 | * * 13 | * TOOL-CHAIN : Any * 14 | * * 15 | * DESCRIPTION : * 16 | * Cpu settings header file. * 17 | * * 18 | **************************************************************************/ 19 | 20 | #ifndef __CPU_H__ 21 | #define __CPU_H__ 22 | 23 | #define BYTE_ORDER BIG_ENDIAN 24 | 25 | #endif /* __CPU_H__ */ 26 | 27 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/include/arch/little/cpu.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * PROJECT : uCOS_LWIP (uC/OS LwIP port) * 4 | * * 5 | * MODULE : CPU.h * 6 | * * 7 | * AUTHOR : Michael Anburaj * 8 | * URL : http://geocities.com/michaelanburaj/ * 9 | * EMAIL: michaelanburaj@hotmail.com * 10 | * * 11 | * PROCESSOR : Any * 12 | * * 13 | * TOOL-CHAIN : Any * 14 | * * 15 | * DESCRIPTION : * 16 | * Cpu settings header file. * 17 | * * 18 | **************************************************************************/ 19 | 20 | #ifndef __CPU_H__ 21 | #define __CPU_H__ 22 | 23 | #define BYTE_ORDER LITTLE_ENDIAN 24 | 25 | #endif /* __CPU_H__ */ 26 | 27 | -------------------------------------------------------------------------------- /test/unit/core/test_mem.c: -------------------------------------------------------------------------------- 1 | #include "test_mem.h" 2 | 3 | #include "lwip/mem.h" 4 | #include "lwip/stats.h" 5 | 6 | #if !LWIP_STATS || !MEM_STATS 7 | #error "This tests needs MEM-statistics enabled" 8 | #endif 9 | #if LWIP_DNS 10 | #error "This test needs DNS turned off (as it mallocs on init)" 11 | #endif 12 | 13 | /* Setups/teardown functions */ 14 | 15 | static void 16 | mem_setup(void) 17 | { 18 | } 19 | 20 | static void 21 | mem_teardown(void) 22 | { 23 | } 24 | 25 | 26 | /* Test functions */ 27 | 28 | /** Call mem_malloc, mem_free and mem_trim and check stats */ 29 | START_TEST(test_mem_one) 30 | { 31 | #define SIZE1 16 32 | #define SIZE1_2 12 33 | #define SIZE2 16 34 | void *p1, *p2; 35 | mem_size_t s1, s2; 36 | LWIP_UNUSED_ARG(_i); 37 | 38 | #if LWIP_DNS 39 | fail("This test needs DNS turned off (as it mallocs on init)"); 40 | #endif 41 | 42 | fail_unless(lwip_stats.mem.used == 0); 43 | 44 | p1 = mem_malloc(SIZE1); 45 | fail_unless(p1 != NULL); 46 | fail_unless(lwip_stats.mem.used >= SIZE1); 47 | s1 = lwip_stats.mem.used; 48 | 49 | p2 = mem_malloc(SIZE2); 50 | fail_unless(p2 != NULL); 51 | fail_unless(lwip_stats.mem.used >= SIZE2 + s1); 52 | s2 = lwip_stats.mem.used; 53 | 54 | mem_trim(p1, SIZE1_2); 55 | 56 | mem_free(p2); 57 | fail_unless(lwip_stats.mem.used <= s2 - SIZE2); 58 | 59 | mem_free(p1); 60 | fail_unless(lwip_stats.mem.used == 0); 61 | } 62 | END_TEST 63 | 64 | 65 | /** Create the suite including all tests for this module */ 66 | Suite * 67 | mem_suite(void) 68 | { 69 | testfunc tests[] = { 70 | TESTFUNC(test_mem_one) 71 | }; 72 | return create_suite("MEM", tests, sizeof(tests)/sizeof(testfunc), mem_setup, mem_teardown); 73 | } 74 | -------------------------------------------------------------------------------- /src/include/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/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 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 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 | 34 | -------------------------------------------------------------------------------- /src/contrib/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 __TAPIF_H__ 33 | #define __TAPIF_H__ 34 | 35 | #include "lwip/netif.h" 36 | 37 | err_t tapif_init(struct netif *netif); 38 | 39 | #endif /* __TAPIF_H__ */ 40 | -------------------------------------------------------------------------------- /src/contrib/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 __PCAPIF_H__ 33 | #define __PCAPIF_H__ 34 | 35 | #include "lwip/netif.h" 36 | 37 | err_t pcapif_init(struct netif *netif); 38 | 39 | #endif /* __PCAPIF_H__ */ 40 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/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 | #ifndef __ARCH_PERF_H__ 33 | #define __ARCH_PERF_H__ 34 | 35 | #define PERF_START /* null definition */ 36 | #define PERF_STOP(x) /* null definition */ 37 | 38 | #endif /* __ARCH_PERF_H__ */ 39 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/include/netif/tunif.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 __TUNIF_H__ 33 | #define __TUNIF_H__ 34 | 35 | #include "lwip/netif.h" 36 | 37 | #include "lwip/pbuf.h" 38 | 39 | err_t tunif_init(struct netif *netif); 40 | 41 | #endif /* __TUNIF_H__ */ 42 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/include/netif/dropif.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 __DROPIF_H__ 33 | #define __DROPIF_H__ 34 | 35 | #include "lwip/netif.h" 36 | 37 | #include "lwip/pbuf.h" 38 | 39 | err_t dropif_init(struct netif *netif); 40 | 41 | #endif /* __DROPIF_H__ */ 42 | -------------------------------------------------------------------------------- /src/contrib/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 suposed 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 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 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/contrib/ports/unix/include/netif/tcpdump.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 __NETIF_TCPDUMP_H__ 33 | #define __NETIF_TCPDUMP_H__ 34 | 35 | #include "lwip/pbuf.h" 36 | 37 | void tcpdump_init(void); 38 | void tcpdump(struct pbuf *p); 39 | 40 | #endif /* __NETIF_TCPDUMP_H__ */ 41 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/include/netif/unixif.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 __UNIXIF_H__ 33 | #define __UNIXIF_H__ 34 | 35 | #include "lwip/netif.h" 36 | 37 | err_t unixif_init_server(struct netif *netif); 38 | err_t unixif_init_client(struct netif *netif); 39 | 40 | #endif /* __UNIXIF_H__ */ 41 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/include/netif/delif.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 __DELIF_H__ 33 | #define __DELIF_H__ 34 | 35 | #include "lwip/netif.h" 36 | 37 | #include "lwip/pbuf.h" 38 | 39 | err_t delif_init(struct netif *netif); 40 | err_t delif_init_thread(struct netif *netif); 41 | 42 | #endif /* __DELIF_H__ */ 43 | -------------------------------------------------------------------------------- /test/unit/tcp/tcp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_HELPER_H__ 2 | #define __TCP_HELPER_H__ 3 | 4 | #include "../lwip_check.h" 5 | #include "lwip/arch.h" 6 | #include "lwip/tcp.h" 7 | #include "lwip/netif.h" 8 | 9 | /* counters used for test_tcp_counters_* callback functions */ 10 | struct test_tcp_counters { 11 | u32_t recv_calls; 12 | u32_t recved_bytes; 13 | u32_t recv_calls_after_close; 14 | u32_t recved_bytes_after_close; 15 | u32_t close_calls; 16 | u32_t err_calls; 17 | err_t last_err; 18 | char* expected_data; 19 | u32_t expected_data_len; 20 | }; 21 | 22 | struct test_tcp_txcounters { 23 | u32_t num_tx_calls; 24 | u32_t num_tx_bytes; 25 | u8_t copy_tx_packets; 26 | struct pbuf *tx_packets; 27 | }; 28 | 29 | /* Helper functions */ 30 | void tcp_remove_all(void); 31 | 32 | struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, 33 | u16_t src_port, u16_t dst_port, void* data, size_t data_len, 34 | u32_t seqno, u32_t ackno, u8_t headerflags); 35 | struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, 36 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags); 37 | struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, 38 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd); 39 | void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, 40 | ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port); 41 | void test_tcp_counters_err(void* arg, err_t err); 42 | err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); 43 | 44 | struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters); 45 | 46 | void test_tcp_input(struct pbuf *p, struct netif *inp); 47 | 48 | void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, 49 | ip_addr_t *ip_addr, ip_addr_t *netmask); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/core/ipv6/dhcp6.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * DHCPv6. 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_DHCP6 /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/ip6_addr.h" 47 | #include "lwip/def.h" 48 | 49 | 50 | #endif /* LWIP_IPV6_DHCP6 */ 51 | -------------------------------------------------------------------------------- /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/inet6.h" 48 | 49 | /** @see ip6_addr.c for implementation of functions. */ 50 | 51 | #endif /* LWIP_IPV6 */ 52 | -------------------------------------------------------------------------------- /src/include/ipv6/lwip/dhcp6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 address autoconfiguration as per RFC 4862. 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 | * IPv6 address autoconfiguration as per RFC 4862. 38 | * 39 | * Please coordinate changes and requests with Ivan Delamer 40 | * 41 | */ 42 | 43 | #ifndef __LWIP_IP6_DHCP6_H__ 44 | #define __LWIP_IP6_DHCP6_H__ 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */ 49 | 50 | 51 | struct dhcp6 52 | { 53 | /*TODO: implement DHCP6*/ 54 | }; 55 | 56 | #endif /* LWIP_IPV6_DHCP6 */ 57 | 58 | #endif /* __LWIP_IP6_DHCP6_H__ */ 59 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/include/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * PROJECT : uCOS_LWIP (uC/OS LwIP port) * 4 | * * 5 | * MODULE : SYS_ARCH.h * 6 | * * 7 | * AUTHOR : Michael Anburaj * 8 | * URL : http://geocities.com/michaelanburaj/ * 9 | * EMAIL: michaelanburaj@hotmail.com * 10 | * * 11 | * PROCESSOR : Any * 12 | * * 13 | * TOOL-CHAIN : Any * 14 | * * 15 | * DESCRIPTION : * 16 | * Interface header file for sys_arch. * 17 | * * 18 | **************************************************************************/ 19 | 20 | #ifndef __SYS_ARCH__H__ 21 | #define __SYS_ARCH__H__ 22 | 23 | /* We don't have Mutexes on UCOSII */ 24 | #define LWIP_COMPAT_MUTEX 1 25 | 26 | #include "os_cpu.h" 27 | #include "os_cfg.h" 28 | #include "ucos_ii.h" 29 | #include "arch/sys_arch_opts.h" 30 | 31 | #define SYS_MBOX_NULL NULL 32 | #define SYS_SEM_NULL NULL 33 | 34 | typedef struct { 35 | /** The mail queue itself. */ 36 | OS_EVENT* pQ; 37 | /** The elements in the queue. */ 38 | void* pvQEntries[LWIP_Q_SIZE]; 39 | /** The semaphore used to count the number of available slots. */ 40 | OS_EVENT* Q_full; 41 | /** The validity flag. */ 42 | int is_valid; 43 | } sys_mbox_t; 44 | 45 | typedef struct { 46 | OS_EVENT* sem; 47 | int is_valid; 48 | } sys_sem_t; 49 | 50 | typedef INT8U sys_thread_t; 51 | 52 | typedef OS_CPU_SR sys_prot_t; 53 | 54 | 55 | #endif /* __SYS_ARCH__H__ */ 56 | 57 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/include/arch/sys_arch_opts.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * PROJECT : uCOS_LWIP (uC/OS LwIP port) * 4 | * * 5 | * MODULE : SYS_ARCH_OPTS.h * 6 | * * 7 | * AUTHOR : Michael Anburaj * 8 | * URL : http://geocities.com/michaelanburaj/ * 9 | * EMAIL: michaelanburaj@hotmail.com * 10 | * * 11 | * PROCESSOR : Any * 12 | * * 13 | * TOOL-CHAIN : Any * 14 | * * 15 | * DESCRIPTION : * 16 | * Module configuration for sys_arch. * 17 | * * 18 | **************************************************************************/ 19 | 20 | 21 | #ifndef __SYS_ARCH_OPTS_H__ 22 | #define __SYS_ARCH_OPTS_H__ 23 | 24 | 25 | /* ********************************************************************* */ 26 | /* Module configuration */ 27 | 28 | #define LWIP_MAX_TASKS 4 /* Number of LwIP tasks */ 29 | #define LWIP_STACK_SIZE 4096 /* Stack size for LwIP tasks */ 30 | /* Note: 31 | Task priorities, LWIP_START_PRIO through (LWIP_START_PRIO+LWIP_MAX_TASKS-1) must be reserved 32 | for LwIP and must not used by other applications outside. */ 33 | 34 | #define LWIP_Q_SIZE 10 /* LwIP queue size */ 35 | #define LWIP_MAX_QS 20 /* Max. LwIP queues */ 36 | 37 | 38 | /* ********************************************************************* */ 39 | /* Interface macro & data definition */ 40 | 41 | 42 | /* ********************************************************************* */ 43 | /* Interface function definition */ 44 | 45 | 46 | #endif /* __SYS_ARCH_OPTS_H__ */ 47 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/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 | #include "arch/perf.h" 34 | 35 | #include 36 | 37 | static FILE *f; 38 | 39 | void 40 | perf_print(unsigned long c1l, unsigned long c1h, 41 | unsigned long c2l, unsigned long c2h, 42 | char *key) 43 | { 44 | unsigned long sub_ms, sub_ls; 45 | 46 | sub_ms = c2h - c1h; 47 | sub_ls = c2l - c1l; 48 | if (c2l < c1l) sub_ms--; 49 | fprintf(f, "%s: %.8lu%.8lu\n", key, sub_ms, sub_ls); 50 | fflush(NULL); 51 | } 52 | 53 | void 54 | perf_print_times(struct tms *start, struct tms *end, char *key) 55 | { 56 | fprintf(f, "%s: %lu\n", key, end->tms_stime - start->tms_stime); 57 | fflush(NULL); 58 | } 59 | 60 | void 61 | perf_init(char *fname) 62 | { 63 | f = fopen(fname, "w"); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/core/sys.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Operating System abstraction 4 | * 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 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/sys.h" 42 | 43 | /* Most of the functions defined in sys.h must be implemented in the 44 | * architecture-dependent file sys_arch.c */ 45 | 46 | #if !NO_SYS 47 | 48 | #ifndef sys_msleep 49 | /** 50 | * Sleep for some ms. Timeouts are NOT processed while sleeping. 51 | * 52 | * @param ms number of milliseconds to sleep 53 | */ 54 | void 55 | sys_msleep(u32_t ms) 56 | { 57 | if (ms > 0) { 58 | sys_sem_t delaysem; 59 | err_t err = sys_sem_new(&delaysem, 0); 60 | if (err == ERR_OK) { 61 | sys_arch_sem_wait(&delaysem, ms); 62 | sys_sem_free(&delaysem); 63 | } 64 | } 65 | } 66 | #endif /* sys_msleep */ 67 | 68 | #endif /* !NO_SYS */ 69 | -------------------------------------------------------------------------------- /src/include/ipv6/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_ETHIP6_H__ 43 | #define __LWIP_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, ip6_addr_t *ip6addr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_IPV6 && LWIP_ETHERNET */ 67 | 68 | #endif /* __LWIP_ETHIP6_H__ */ 69 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/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 | #ifndef __ARCH_SYS_ARCH_H__ 33 | #define __ARCH_SYS_ARCH_H__ 34 | 35 | #include 36 | 37 | #define SYS_MBOX_NULL NULL 38 | #define SYS_SEM_NULL NULL 39 | 40 | typedef u32_t sys_prot_t; 41 | 42 | struct sys_sem; 43 | typedef struct sys_sem * sys_sem_t; 44 | #define sys_sem_valid(sem) (((sem) != NULL) && (*(sem) != NULL)) 45 | #define sys_sem_set_invalid(sem) do { if((sem) != NULL) { *(sem) = NULL; }}while(0) 46 | 47 | /* let sys.h use binary semaphores for mutexes */ 48 | #define LWIP_COMPAT_MUTEX 1 49 | 50 | struct sys_mbox; 51 | typedef struct sys_mbox *sys_mbox_t; 52 | #define sys_mbox_valid(mbox) (((mbox) != NULL) && (*(mbox) != NULL)) 53 | #define sys_mbox_set_invalid(mbox) do { if((mbox) != NULL) { *(mbox) = NULL; }}while(0) 54 | 55 | struct sys_thread; 56 | typedef struct sys_thread * sys_thread_t; 57 | 58 | #endif /* __ARCH_SYS_ARCH_H__ */ 59 | 60 | -------------------------------------------------------------------------------- /test/unit/lwipopts.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: Simon Goldschmidt 30 | * 31 | */ 32 | #ifndef __LWIPOPTS_H__ 33 | #define __LWIPOPTS_H__ 34 | 35 | /* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */ 36 | #define NO_SYS 1 37 | #define LWIP_NETCONN 0 38 | #define LWIP_SOCKET 0 39 | 40 | /* Enable DHCP to test it, disable UDP checksum to easier inject packets */ 41 | #define LWIP_DHCP 1 42 | 43 | /* Minimal changes to opt.h required for tcp unit tests: */ 44 | #define MEM_SIZE 16000 45 | #define TCP_SND_QUEUELEN 40 46 | #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN 47 | #define TCP_SND_BUF (12 * TCP_MSS) 48 | #define TCP_WND (10 * TCP_MSS) 49 | #define LWIP_WND_SCALE 1 50 | #define TCP_RCV_SCALE 0 51 | #define PBUF_POOL_SIZE 400 // pbuf tests need ~200KByte 52 | 53 | /* Minimal changes to opt.h required for etharp unit tests: */ 54 | #define ETHARP_SUPPORT_STATIC_ENTRIES 1 55 | 56 | #endif /* __LWIPOPTS_H__ */ 57 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/include/netif/sio.h: -------------------------------------------------------------------------------- 1 | #ifndef SIO_H 2 | #define SIO_H 3 | 4 | #include "lwip/sys.h" 5 | #include "lwip/netif.h" 6 | #include "netif/fifo.h" 7 | /*#include "netif/pppif.h"*/ 8 | /* BAUDRATE is defined in sio.c as it is implementation specific */ 9 | 10 | typedef struct sio_status_t { 11 | int fd; 12 | fifo_t myfifo; 13 | } sio_status_t; 14 | 15 | 16 | /** Baudrates */ 17 | typedef enum sioBaudrates { 18 | SIO_BAUD_9600, 19 | SIO_BAUD_19200, 20 | SIO_BAUD_38400, 21 | SIO_BAUD_57600, 22 | SIO_BAUD_115200 23 | } sioBaudrates; 24 | 25 | /** 26 | * Read a char from incoming data stream, this call blocks until data has arrived 27 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 28 | * @return char read from input stream 29 | */ 30 | u8_t sio_recv( sio_status_t * siostat ); 31 | 32 | /** 33 | * Poll for a new character from incoming data stream 34 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 35 | * @return char read from input stream, or < 0 if no char was available 36 | */ 37 | s16_t sio_poll(sio_status_t * siostat); 38 | 39 | /** 40 | * Parse incoming characters until a string str is recieved, blocking call 41 | * @param str zero terminated string to expect 42 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 43 | */ 44 | void sio_expect_string(u8_t *str, sio_status_t * siostat); 45 | 46 | /** 47 | * Write a char to output data stream 48 | * @param c char to write to output stream 49 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 50 | */ 51 | void sio_send( u8_t c, sio_status_t * siostat ); 52 | 53 | /** 54 | * Write a char to output data stream 55 | * @param str pointer to a zero terminated string 56 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 57 | */ 58 | void sio_send_string(u8_t *str, sio_status_t * siostat); 59 | 60 | /** 61 | * Flush outbuffer (send everything in buffer now), useful if some layer below is 62 | * holding on to data, waitng to fill a buffer 63 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 64 | */ 65 | void sio_flush( sio_status_t * siostat ); 66 | 67 | /** 68 | * Open serial port entry point from serial protocol (slipif, pppif) 69 | * @param devnum the device number to use, i.e. ttySx, comx:, etc. there x = devnum 70 | * @return siostatus struct, contains sio instance data, use when calling sio functions 71 | */ 72 | sio_status_t * sio_open( int devnum ); 73 | 74 | /** 75 | * Change baudrate of port, may close and reopen port 76 | * @param baud new baudrate 77 | * @param siostat siostatus struct, contains sio instance data, given by sio_open 78 | */ 79 | void sio_change_baud( sioBaudrates baud, sio_status_t * siostat ); 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/lwip_chksum.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 | #include "lwip/debug.h" 34 | 35 | #include "lwip/arch.h" 36 | 37 | #include "lwip/def.h" 38 | #include "lwip/inet.h" 39 | 40 | 41 | /*-----------------------------------------------------------------------------------*/ 42 | /* lwip_chksum: 43 | * 44 | * Sums up all 16 bit words in a memory portion. Also includes any odd byte. 45 | * This function is used by the other checksum functions. 46 | * 47 | */ 48 | /*-----------------------------------------------------------------------------------*/ 49 | #if 0 50 | u16_t 51 | lwip_chksum(void *dataptr, int len) 52 | { 53 | u32_t acc; 54 | 55 | for(acc = 0; len > 1; len -= 2) { 56 | acc += *((u16_t *)dataptr)++; 57 | } 58 | 59 | /* add up any odd byte */ 60 | if (len == 1) { 61 | acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8); 62 | LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", *(u8_t *)dataptr)); 63 | } 64 | acc = (acc >> 16) + (acc & 0xffffUL); 65 | 66 | if (acc & 0xffff0000 != 0) { 67 | acc = (acc >> 16) + (acc & 0xffffUL); 68 | } 69 | 70 | return (u16_t)acc; 71 | } 72 | /*-----------------------------------------------------------------------------------*/ 73 | #endif 74 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/include/arch/cc.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * PROJECT : uCOS_LWIP (uC/OS LwIP port) * 4 | * * 5 | * MODULE : CC.h * 6 | * * 7 | * AUTHOR : Michael Anburaj * 8 | * URL : http://geocities.com/michaelanburaj/ * 9 | * EMAIL: michaelanburaj@hotmail.com * 10 | * * 11 | * PROCESSOR : Any * 12 | * * 13 | * TOOL-CHAIN : Any * 14 | * * 15 | * DESCRIPTION : * 16 | * Architecture related header. * 17 | * * 18 | **************************************************************************/ 19 | 20 | #ifndef __ARCH_CC_H__ 21 | #define __ARCH_CC_H__ 22 | 23 | /* Include some files for defining library routines */ 24 | #include 25 | #include "little/cpu.h" 26 | #include 27 | 28 | /* Define platform endianness */ 29 | #ifndef BYTE_ORDER 30 | #define BYTE_ORDER LITTLE_ENDIAN 31 | #endif /* BYTE_ORDER */ 32 | 33 | /* Define generic types used in lwIP */ 34 | typedef uint8_t u8_t; 35 | typedef int8_t s8_t; 36 | typedef uint16_t u16_t; 37 | typedef int16_t s16_t; 38 | typedef uint32_t u32_t; 39 | typedef int32_t s32_t; 40 | typedef intptr_t mem_ptr_t; 41 | 42 | /* Compiler hints for packing structures */ 43 | #define PACK_STRUCT_FIELD(x) x __attribute__((packed)) 44 | #define PACK_STRUCT_STRUCT __attribute__((packed)) 45 | #define PACK_STRUCT_BEGIN 46 | #define PACK_STRUCT_END 47 | 48 | /* prototypes for printf() and abort() */ 49 | #include 50 | #include 51 | 52 | /* XXX Do something useful .*/ 53 | #define panic(s) {printf("%s:%d : %s", __FILE__, __LINE__, (s));while(1);} 54 | 55 | /* Non-fatal, prints a message. Uses printf formatting. */ 56 | #define LWIP_PLATFORM_DIAG(x) {printf x;} 57 | 58 | /* Fatal, print message and abandon execution. Uses printf formating. The panic() function never returns. */ 59 | #define LWIP_PLATFORM_ASSERT(x) { panic((x)); } 60 | 61 | #define SYS_ARCH_DECL_PROTECT(x) OS_CPU_SR cpu_sr 62 | #define SYS_ARCH_PROTECT(x) OS_ENTER_CRITICAL() 63 | #define SYS_ARCH_UNPROTECT(x) OS_EXIT_CRITICAL() 64 | 65 | #endif /* __ARCH_CC_H__ */ 66 | 67 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/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 | #ifndef __ARCH_PERF_H__ 33 | #define __ARCH_PERF_H__ 34 | 35 | typedef long int clock_t; 36 | #include 37 | #include 38 | 39 | #ifdef PERF 40 | #define PERF_START { \ 41 | unsigned long __c1l, __c1h, __c2l, __c2h; \ 42 | __asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h)) 43 | #define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \ 44 | perf_print(__c1l, __c1h, __c2l, __c2h, x);} 45 | 46 | /*#define PERF_START do { \ 47 | struct tms __perf_start, __perf_end; \ 48 | times(&__perf_start) 49 | #define PERF_STOP(x) times(&__perf_end); \ 50 | perf_print_times(&__perf_start, &__perf_end, x);\ 51 | } while(0)*/ 52 | #else /* PERF */ 53 | #define PERF_START /* null definition */ 54 | #define PERF_STOP(x) /* null definition */ 55 | #endif /* PERF */ 56 | 57 | void perf_print(unsigned long c1l, unsigned long c1h, 58 | unsigned long c2l, unsigned long c2h, 59 | char *key); 60 | 61 | void perf_print_times(struct tms *start, struct tms *end, char *key); 62 | 63 | void perf_init(char *fname); 64 | 65 | #endif /* __ARCH_PERF_H__ */ 66 | -------------------------------------------------------------------------------- /src/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 | #ifndef PPPDEBUG_H 37 | #define PPPDEBUG_H 38 | 39 | /* Trace levels. */ 40 | #define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 41 | #define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 42 | #define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 43 | #define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 44 | #define LOG_INFO (PPP_DEBUG) 45 | #define LOG_DETAIL (PPP_DEBUG) 46 | #define LOG_DEBUG (PPP_DEBUG) 47 | 48 | 49 | #define TRACELCP PPP_DEBUG 50 | 51 | #if PPP_DEBUG 52 | 53 | #define AUTHDEBUG(a, b) LWIP_DEBUGF(a, b) 54 | #define IPCPDEBUG(a, b) LWIP_DEBUGF(a, b) 55 | #define UPAPDEBUG(a, b) LWIP_DEBUGF(a, b) 56 | #define LCPDEBUG(a, b) LWIP_DEBUGF(a, b) 57 | #define FSMDEBUG(a, b) LWIP_DEBUGF(a, b) 58 | #define CHAPDEBUG(a, b) LWIP_DEBUGF(a, b) 59 | #define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) 60 | 61 | #else /* PPP_DEBUG */ 62 | 63 | #define AUTHDEBUG(a, b) 64 | #define IPCPDEBUG(a, b) 65 | #define UPAPDEBUG(a, b) 66 | #define LCPDEBUG(a, b) 67 | #define FSMDEBUG(a, b) 68 | #define CHAPDEBUG(a, b) 69 | #define PPPDEBUG(a, b) 70 | 71 | #endif /* PPP_DEBUG */ 72 | 73 | #endif /* PPPDEBUG_H */ 74 | -------------------------------------------------------------------------------- /src/netif/ppp/magic.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * magic.h - Network Random Number Generator header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1997 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original derived from BSD codes. 32 | *****************************************************************************/ 33 | /* 34 | * magic.h - PPP Magic Number definitions. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | * 51 | * $Id: magic.h,v 1.3 2010/01/18 20:49:43 goldsimon Exp $ 52 | */ 53 | 54 | #ifndef MAGIC_H 55 | #define MAGIC_H 56 | 57 | /* Initialize the magic number generator */ 58 | void magicInit(void); 59 | 60 | /* Returns the next magic number */ 61 | u32_t magic(void); 62 | 63 | #endif /* MAGIC_H */ 64 | -------------------------------------------------------------------------------- /src/contrib/ports/ucos-ii/lib.c: -------------------------------------------------------------------------------- 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 | * $Id: lib.c,v 1.1 2003/01/18 18:21:57 jani Exp $ 34 | */ 35 | 36 | /* These are generic implementations of various library functions used 37 | * throughout the lwIP code. When porting, those should be optimized 38 | * for the particular processor architecture, preferably coded in 39 | * assembler. 40 | */ 41 | 42 | #include "lwip/arch.h" 43 | 44 | #if BYTE_ORDER == LITTLE_ENDIAN 45 | /*-----------------------------------------------------------------------------------*/ 46 | u16_t 47 | htons(u16_t n) 48 | { 49 | return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); 50 | } 51 | /*-----------------------------------------------------------------------------------*/ 52 | u16_t 53 | ntohs(u16_t n) 54 | { 55 | return htons(n); 56 | } 57 | /*-----------------------------------------------------------------------------------*/ 58 | u32_t 59 | htonl(u32_t n) 60 | { 61 | return ((n & 0xff) << 24) | 62 | ((n & 0xff00) << 8) | 63 | ((n & 0xff0000) >> 8) | 64 | ((n & 0xff000000) >> 24); 65 | } 66 | /*-----------------------------------------------------------------------------------*/ 67 | u32_t 68 | ntohl(u32_t n) 69 | { 70 | return htonl(n); 71 | } 72 | /*-----------------------------------------------------------------------------------*/ 73 | #endif /* BYTE_ORDER == LITTLE_ENDIAN */ 74 | -------------------------------------------------------------------------------- /src/netif/ppp/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | *********************************************************************** 3 | ** md5.h -- header file for implementation of MD5 ** 4 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** 5 | ** Created: 2/17/90 RLR ** 6 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** 7 | ** Revised (for MD5): RLR 4/27/91 ** 8 | ** -- G modified to have y&~z instead of y&z ** 9 | ** -- FF, GG, HH modified to add in last register done ** 10 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** 11 | ** -- distinct additive constant for each step ** 12 | ** -- round 4 added, working mod 7 ** 13 | *********************************************************************** 14 | */ 15 | 16 | /* 17 | *********************************************************************** 18 | ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** 19 | ** ** 20 | ** License to copy and use this software is granted provided that ** 21 | ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** 22 | ** Digest Algorithm" in all material mentioning or referencing this ** 23 | ** software or this function. ** 24 | ** ** 25 | ** License is also granted to make and use derivative works ** 26 | ** provided that such works are identified as "derived from the RSA ** 27 | ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** 28 | ** material mentioning or referencing the derived work. ** 29 | ** ** 30 | ** RSA Data Security, Inc. makes no representations concerning ** 31 | ** either the merchantability of this software or the suitability ** 32 | ** of this software for any particular purpose. It is provided "as ** 33 | ** is" without express or implied warranty of any kind. ** 34 | ** ** 35 | ** These notices must be retained in any copies of any part of this ** 36 | ** documentation and/or software. ** 37 | *********************************************************************** 38 | */ 39 | 40 | #ifndef MD5_H 41 | #define MD5_H 42 | 43 | /* Data structure for MD5 (Message-Digest) computation */ 44 | typedef struct { 45 | u32_t i[2]; /* number of _bits_ handled mod 2^64 */ 46 | u32_t buf[4]; /* scratch buffer */ 47 | unsigned char in[64]; /* input buffer */ 48 | unsigned char digest[16]; /* actual digest after MD5Final call */ 49 | } MD5_CTX; 50 | 51 | void MD5Init ( MD5_CTX *mdContext); 52 | void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); 53 | void MD5Final ( unsigned char hash[], MD5_CTX *mdContext); 54 | 55 | #endif /* MD5_H */ 56 | -------------------------------------------------------------------------------- /src/netif/ppp/chpms.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * chpms.h - Network Microsoft Challenge Handshake Protocol header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 98-01-30 Guy Lancaster , Global Election Systems Inc. 31 | * Original built from BSD network code. 32 | ******************************************************************************/ 33 | /* 34 | * chap.h - Challenge Handshake Authentication Protocol definitions. 35 | * 36 | * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. 37 | * http://www.strataware.com/ 38 | * 39 | * All rights reserved. 40 | * 41 | * Redistribution and use in source and binary forms are permitted 42 | * provided that the above copyright notice and this paragraph are 43 | * duplicated in all such forms and that any documentation, 44 | * advertising materials, and other materials related to such 45 | * distribution and use acknowledge that the software was developed 46 | * by Eric Rosenquist. The name of the author may not be used to 47 | * endorse or promote products derived from this software without 48 | * specific prior written permission. 49 | * 50 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 51 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 52 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 53 | * 54 | * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $ 55 | */ 56 | 57 | #ifndef CHPMS_H 58 | #define CHPMS_H 59 | 60 | #define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ 61 | 62 | void ChapMS (chap_state *, char *, int, char *, int); 63 | 64 | #endif /* CHPMS_H */ 65 | -------------------------------------------------------------------------------- /doc/contrib.txt: -------------------------------------------------------------------------------- 1 | 1 Introduction 2 | 3 | This document describes some guidelines for people participating 4 | in lwIP development. 5 | 6 | 2 How to contribute to lwIP 7 | 8 | Here is a short list of suggestions to anybody working with lwIP and 9 | trying to contribute bug reports, fixes, enhancements, platform ports etc. 10 | First of all as you may already know lwIP is a volunteer project so feedback 11 | to fixes or questions might often come late. Hopefully the bug and patch tracking 12 | features of Savannah help us not lose users' input. 13 | 14 | 2.1 Source code style: 15 | 16 | 1. do not use tabs. 17 | 2. indentation is two spaces per level (i.e. per tab). 18 | 3. end debug messages with a trailing newline (\n). 19 | 4. one space between keyword and opening bracket. 20 | 5. no space between function and opening bracket. 21 | 6. one space and no newline before opening curly braces of a block. 22 | 7. closing curly brace on a single line. 23 | 8. spaces surrounding assignment and comparisons. 24 | 9. don't initialize static and/or global variables to zero, the compiler takes care of that. 25 | 10. use current source code style as further reference. 26 | 27 | 2.2 Source code documentation style: 28 | 29 | 1. JavaDoc compliant and Doxygen compatible. 30 | 2. Function documentation above functions in .c files, not .h files. 31 | (This forces you to synchronize documentation and implementation.) 32 | 3. Use current documentation style as further reference. 33 | 34 | 2.3 Bug reports and patches: 35 | 36 | 1. Make sure you are reporting bugs or send patches against the latest 37 | sources. (From the latest release and/or the current CVS sources.) 38 | 2. If you think you found a bug make sure it's not already filed in the 39 | bugtracker at Savannah. 40 | 3. If you have a fix put the patch on Savannah. If it is a patch that affects 41 | both core and arch specific stuff please separate them so that the core can 42 | be applied separately while leaving the other patch 'open'. The prefered way 43 | is to NOT touch archs you can't test and let maintainers take care of them. 44 | This is a good way to see if they are used at all - the same goes for unix 45 | netifs except tapif. 46 | 4. Do not file a bug and post a fix to it to the patch area. Either a bug report 47 | or a patch will be enough. 48 | If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area. 49 | 5. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other 50 | trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you 51 | change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than 52 | if it's not to the point and long :) so the chances for it to be applied are greater. 53 | 54 | 2.4 Platform porters: 55 | 56 | 1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and 57 | you think it could benefit others[1] you might want discuss this on the mailing list. You 58 | can also ask for CVS access to submit and maintain your port in the contrib CVS module. 59 | -------------------------------------------------------------------------------- /src/include/lwip/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_INIT_H__ 33 | #define __LWIP_INIT_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** X.x.x: Major version of the stack */ 42 | #define LWIP_VERSION_MAJOR 1U 43 | /** x.X.x: Minor version of the stack */ 44 | #define LWIP_VERSION_MINOR 4U 45 | /** x.x.X: Revision of the stack */ 46 | #define LWIP_VERSION_REVISION 1U 47 | /** For release candidates, this is set to 1..254 48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 49 | * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 50 | #define LWIP_VERSION_RC 0U 51 | 52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 53 | #define LWIP_RC_RELEASE 255U 54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ 55 | #define LWIP_RC_DEVELOPMENT 0U 56 | 57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 60 | 61 | /** Provides the version of the stack */ 62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ 63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) 64 | 65 | /* Modules initialization */ 66 | void lwip_init(void); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __LWIP_INIT_H__ */ 73 | -------------------------------------------------------------------------------- /src/api/err.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Error Management module 4 | * 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 | 39 | #include "lwip/err.h" 40 | 41 | #ifdef LWIP_DEBUG 42 | 43 | static const char *err_strerr[] = { 44 | "Ok.", /* ERR_OK 0 */ 45 | "Out of memory error.", /* ERR_MEM -1 */ 46 | "Buffer error.", /* ERR_BUF -2 */ 47 | "Timeout.", /* ERR_TIMEOUT -3 */ 48 | "Routing problem.", /* ERR_RTE -4 */ 49 | "Operation in progress.", /* ERR_INPROGRESS -5 */ 50 | "Illegal value.", /* ERR_VAL -6 */ 51 | "Operation would block.", /* ERR_WOULDBLOCK -7 */ 52 | "Address in use.", /* ERR_USE -8 */ 53 | "Already connected.", /* ERR_ISCONN -9 */ 54 | "Connection aborted.", /* ERR_ABRT -10 */ 55 | "Connection reset.", /* ERR_RST -11 */ 56 | "Connection closed.", /* ERR_CLSD -12 */ 57 | "Not connected.", /* ERR_CONN -13 */ 58 | "Illegal argument.", /* ERR_ARG -14 */ 59 | "Low-level netif error.", /* ERR_IF -15 */ 60 | }; 61 | 62 | /** 63 | * Convert an lwip internal error to a string representation. 64 | * 65 | * @param err an lwip internal err_t 66 | * @return a string representation for err 67 | */ 68 | const char * 69 | lwip_strerr(err_t err) 70 | { 71 | return err_strerr[-err]; 72 | 73 | } 74 | 75 | #endif /* LWIP_DEBUG */ 76 | -------------------------------------------------------------------------------- /src/netif/ppp/magic.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * magic.c - Network Random Number Generator program file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1997 by Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original based on BSD magic.c. 32 | *****************************************************************************/ 33 | /* 34 | * magic.c - PPP Magic Number routines. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | */ 51 | 52 | #include "lwip/opt.h" 53 | 54 | #if PPP_SUPPORT 55 | 56 | #include "ppp_impl.h" 57 | #include "randm.h" 58 | #include "magic.h" 59 | 60 | 61 | /* 62 | * magicInit - Initialize the magic number generator. 63 | * 64 | * Since we use another random number generator that has its own 65 | * initialization, we do nothing here. 66 | */ 67 | void magicInit() 68 | { 69 | return; 70 | } 71 | 72 | /* 73 | * magic - Returns the next magic number. 74 | */ 75 | u32_t magic() 76 | { 77 | return avRandom(); 78 | } 79 | 80 | #endif /* PPP_SUPPORT */ 81 | -------------------------------------------------------------------------------- /src/include/netif/slipif.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 __NETIF_SLIPIF_H__ 35 | #define __NETIF_SLIPIF_H__ 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/netif.h" 39 | 40 | /** Set this to 1 to start a thread that blocks reading on the serial line 41 | * (using sio_read()). 42 | */ 43 | #ifndef SLIP_USE_RX_THREAD 44 | #define SLIP_USE_RX_THREAD !NO_SYS 45 | #endif 46 | 47 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 48 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 49 | * packets on a queue, which is fed into lwIP from slipif_poll(). 50 | * If disabled, slipif_poll() polls the serila line (using sio_tryread()). 51 | */ 52 | #ifndef SLIP_RX_FROM_ISR 53 | #define SLIP_RX_FROM_ISR 0 54 | #endif 55 | 56 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 57 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 58 | * If disabled, packets will be dropped if more than one packet is received. 59 | */ 60 | #ifndef SLIP_RX_QUEUE 61 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | err_t slipif_init(struct netif * netif); 69 | void slipif_poll(struct netif *netif); 70 | #if SLIP_RX_FROM_ISR 71 | void slipif_process_rxqueue(struct netif *netif); 72 | void slipif_received_byte(struct netif *netif, u8_t data); 73 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 74 | #endif /* SLIP_RX_FROM_ISR */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /src/include/ipv4/lwip/ip_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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: Jani Monoses 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_IP_FRAG_H__ 34 | #define __LWIP_IP_FRAG_H__ 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/netif.h" 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/ip.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if IP_REASSEMBLY 48 | /* The IP reassembly timer interval in milliseconds. */ 49 | #define IP_TMR_INTERVAL 1000 50 | 51 | /* IP reassembly helper struct. 52 | * This is exported because memp needs to know the size. 53 | */ 54 | struct ip_reassdata { 55 | struct ip_reassdata *next; 56 | struct pbuf *p; 57 | struct ip_hdr iphdr; 58 | u16_t datagram_len; 59 | u8_t flags; 60 | u8_t timer; 61 | }; 62 | 63 | void ip_reass_init(void); 64 | void ip_reass_tmr(void); 65 | struct pbuf * ip_reass(struct pbuf *p); 66 | #endif /* IP_REASSEMBLY */ 67 | 68 | #if IP_FRAG 69 | #if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 70 | /** A custom pbuf that holds a reference to another pbuf, which is freed 71 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 72 | * that points into the original pbuf. */ 73 | #ifndef __LWIP_PBUF_CUSTOM_REF__ 74 | #define __LWIP_PBUF_CUSTOM_REF__ 75 | struct pbuf_custom_ref { 76 | /** 'base class' */ 77 | struct pbuf_custom pc; 78 | /** pointer to the original pbuf that is referenced */ 79 | struct pbuf *original; 80 | }; 81 | #endif /* __LWIP_PBUF_CUSTOM_REF__ */ 82 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 83 | 84 | err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest); 85 | #endif /* IP_FRAG */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* __LWIP_IP_FRAG_H__ */ 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lwIP Stack 2 | [![Build Status](https://travis-ci.org/cvra/lwip_ucos2.png)](http://travis-ci.org/cvra/lwip_ucos2) 3 | ## Introduction 4 | 5 | lwIP is a small independent implementation of the TCP/IP protocol 6 | suite that has been developed by Adam Dunkels at the Computer and 7 | Networks Architectures (CNA) lab at the Swedish Institute of Computer 8 | Science (SICS). 9 | 10 | The focus of the lwIP TCP/IP implementation is to reduce the RAM usage 11 | while still having a full scale TCP. This making lwIP suitable for use 12 | in embedded systems with tens of kilobytes of free RAM and room for 13 | around 40 kilobytes of code ROM. 14 | 15 | ## Features 16 | * IP (Internet Protocol) including packet forwarding over multiple network 17 | interfaces 18 | * ICMP (Internet Control Message Protocol) for network maintenance and debugging 19 | * IGMP (Internet Group Management Protocol) for multicast traffic management 20 | * UDP (User Datagram Protocol) including experimental UDP-lite extensions 21 | * TCP (Transmission Control Protocol) with congestion control, RTT estimation 22 | and fast recovery/fast retransmit 23 | * Specialized raw/native API for enhanced performance 24 | * Optional Berkeley-like socket API 25 | * DNS (Domain names resolver) 26 | * SNMP (Simple Network Management Protocol) 27 | * DHCP (Dynamic Host Configuration Protocol) 28 | * AUTOIP (for IPv4, conform with RFC 3927) 29 | * PPP (Point-to-Point Protocol) 30 | * ARP (Address Resolution Protocol) for Ethernet 31 | 32 | ## License 33 | lwIP is freely available under a BSD license. 34 | 35 | ## Development 36 | 37 | lwIP has grown into an excellent TCP/IP stack for embedded devices, 38 | and developers using the stack often submit bug fixes, improvements, 39 | and additions to the stack to further increase its usefulness. 40 | 41 | Development of lwIP is hosted on Savannah, a central point for 42 | software development, maintenance and distribution. Everyone can 43 | help improve lwIP by use of Savannah's interface, CVS and the 44 | mailing list. A core team of developers will commit changes to the 45 | CVS source tree. 46 | 47 | The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and 48 | contributions (such as platform ports) are in the 'contrib' module. 49 | 50 | See doc/savannah.txt for details on CVS server access for users and 51 | developers. 52 | 53 | Submit patches and bugs via the lwIP project page: 54 | http://savannah.nongnu.org/projects/lwip/ 55 | 56 | 57 | ## Documentation 58 | 59 | The original out-dated homepage of lwIP and Adam Dunkels' papers on 60 | lwIP are at the official lwIP home page: 61 | http://www.sics.se/~adam/lwip/ 62 | 63 | Self documentation of the source code is regularly extracted from the 64 | current CVS sources and is available from this web page: 65 | http://www.nongnu.org/lwip/ 66 | 67 | There is now a constantly growin wiki about lwIP at 68 | http://lwip.wikia.com/wiki/LwIP_Wiki 69 | 70 | Also, there are mailing lists you can subscribe at 71 | http://savannah.nongnu.org/mail/?group=lwip 72 | plus searchable archives: 73 | http://lists.nongnu.org/archive/html/lwip-users/ 74 | http://lists.nongnu.org/archive/html/lwip-devel/ 75 | 76 | Reading Adam's papers, the files in docs/, browsing the source code 77 | documentation and browsing the mailing list archives is a good way to 78 | become familiar with the design of lwIP. 79 | 80 | Adam Dunkels 81 | Leon Woestenberg 82 | 83 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/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 | #ifndef __ARCH_CC_H__ 33 | #define __ARCH_CC_H__ 34 | 35 | /* Include some files for defining library routines */ 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | /* Define platform endianness */ 42 | #ifndef BYTE_ORDER 43 | #define BYTE_ORDER LITTLE_ENDIAN 44 | #endif /* BYTE_ORDER */ 45 | 46 | /* Define generic types used in lwIP */ 47 | typedef unsigned char u8_t; 48 | typedef signed char s8_t; 49 | typedef unsigned short u16_t; 50 | typedef signed short s16_t; 51 | typedef unsigned int u32_t; 52 | typedef signed int s32_t; 53 | 54 | typedef unsigned long mem_ptr_t; 55 | 56 | /* Define (sn)printf formatters for these lwIP types */ 57 | #define X8_F "02x" 58 | #define U16_F "hu" 59 | #define S16_F "hd" 60 | #define X16_F "hx" 61 | #define U32_F "u" 62 | #define S32_F "d" 63 | #define X32_F "x" 64 | 65 | /* If only we could use C99 and get %zu */ 66 | #if defined(__x86_64__) 67 | #define SZT_F "lu" 68 | #else 69 | #define SZT_F "u" 70 | #endif 71 | 72 | /* Compiler hints for packing structures */ 73 | #define PACK_STRUCT_FIELD(x) x 74 | #define PACK_STRUCT_STRUCT __attribute__((packed)) 75 | #define PACK_STRUCT_BEGIN 76 | #define PACK_STRUCT_END 77 | 78 | /* prototypes for printf() and abort() */ 79 | #include 80 | #include 81 | /* Plaform specific diagnostic output */ 82 | #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) 83 | 84 | #define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ 85 | x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) 86 | 87 | #define LWIP_RAND() ((u32_t)rand()) 88 | 89 | #endif /* __ARCH_CC_H__ */ 90 | -------------------------------------------------------------------------------- /src/netif/ppp/randm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * randm.h - Random number generator header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 98-05-29 Guy Lancaster , Global Election Systems Inc. 31 | * Extracted from avos. 32 | *****************************************************************************/ 33 | 34 | #ifndef RANDM_H 35 | #define RANDM_H 36 | 37 | /*********************** 38 | *** PUBLIC FUNCTIONS *** 39 | ***********************/ 40 | /* 41 | * Initialize the random number generator. 42 | */ 43 | void avRandomInit(void); 44 | 45 | /* 46 | * Churn the randomness pool on a random event. Call this early and often 47 | * on random and semi-random system events to build randomness in time for 48 | * usage. For randomly timed events, pass a null pointer and a zero length 49 | * and this will use the system timer and other sources to add randomness. 50 | * If new random data is available, pass a pointer to that and it will be 51 | * included. 52 | */ 53 | void avChurnRand(char *randData, u32_t randLen); 54 | 55 | /* 56 | * Randomize our random seed value. To be called for truely random events 57 | * such as user operations and network traffic. 58 | */ 59 | #if MD5_SUPPORT 60 | #define avRandomize() avChurnRand(NULL, 0) 61 | #else /* MD5_SUPPORT */ 62 | void avRandomize(void); 63 | #endif /* MD5_SUPPORT */ 64 | 65 | /* 66 | * Use the random pool to generate random data. This degrades to pseudo 67 | * random when used faster than randomness is supplied using churnRand(). 68 | * Thus it's important to make sure that the results of this are not 69 | * published directly because one could predict the next result to at 70 | * least some degree. Also, it's important to get a good seed before 71 | * the first use. 72 | */ 73 | void avGenRand(char *buf, u32_t bufLen); 74 | 75 | /* 76 | * Return a new random number. 77 | */ 78 | u32_t avRandom(void); 79 | 80 | 81 | #endif /* RANDM_H */ 82 | -------------------------------------------------------------------------------- /src/include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_ERR_H__ 33 | #define __LWIP_ERR_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** Define LWIP_ERR_T in cc.h if you want to use 43 | * a different type for your platform (must be signed). */ 44 | #ifdef LWIP_ERR_T 45 | typedef LWIP_ERR_T err_t; 46 | #else /* LWIP_ERR_T */ 47 | typedef s8_t err_t; 48 | #endif /* LWIP_ERR_T*/ 49 | 50 | /* Definitions for error constants. */ 51 | 52 | #define ERR_OK 0 /* No error, everything OK. */ 53 | #define ERR_MEM -1 /* Out of memory error. */ 54 | #define ERR_BUF -2 /* Buffer error. */ 55 | #define ERR_TIMEOUT -3 /* Timeout. */ 56 | #define ERR_RTE -4 /* Routing problem. */ 57 | #define ERR_INPROGRESS -5 /* Operation in progress */ 58 | #define ERR_VAL -6 /* Illegal value. */ 59 | #define ERR_WOULDBLOCK -7 /* Operation would block. */ 60 | #define ERR_USE -8 /* Address in use. */ 61 | #define ERR_ISCONN -9 /* Already connected. */ 62 | 63 | #define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) 64 | 65 | #define ERR_ABRT -10 /* Connection aborted. */ 66 | #define ERR_RST -11 /* Connection reset. */ 67 | #define ERR_CLSD -12 /* Connection closed. */ 68 | #define ERR_CONN -13 /* Not connected. */ 69 | 70 | #define ERR_ARG -14 /* Illegal argument. */ 71 | 72 | #define ERR_IF -15 /* Low-level netif error */ 73 | 74 | 75 | #ifdef LWIP_DEBUG 76 | extern const char *lwip_strerr(err_t err); 77 | #else 78 | #define lwip_strerr(x) "" 79 | #endif /* LWIP_DEBUG */ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* __LWIP_ERR_H__ */ 86 | -------------------------------------------------------------------------------- /src/core/def.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Common functions used throughout the stack. 4 | * 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: Simon Goldschmidt 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | #include "lwip/def.h" 41 | 42 | /** 43 | * These are reference implementations of the byte swapping functions. 44 | * Again with the aim of being simple, correct and fully portable. 45 | * Byte swapping is the second thing you would want to optimize. You will 46 | * need to port it to your architecture and in your cc.h: 47 | * 48 | * #define LWIP_PLATFORM_BYTESWAP 1 49 | * #define LWIP_PLATFORM_HTONS(x) 50 | * #define LWIP_PLATFORM_HTONL(x) 51 | * 52 | * Note ntohs() and ntohl() are merely references to the htonx counterparts. 53 | */ 54 | 55 | #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) 56 | 57 | /** 58 | * Convert an u16_t from host- to network byte order. 59 | * 60 | * @param n u16_t in host byte order 61 | * @return n in network byte order 62 | */ 63 | u16_t 64 | lwip_htons(u16_t n) 65 | { 66 | return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); 67 | } 68 | 69 | /** 70 | * Convert an u16_t from network- to host byte order. 71 | * 72 | * @param n u16_t in network byte order 73 | * @return n in host byte order 74 | */ 75 | u16_t 76 | lwip_ntohs(u16_t n) 77 | { 78 | return lwip_htons(n); 79 | } 80 | 81 | /** 82 | * Convert an u32_t from host- to network byte order. 83 | * 84 | * @param n u32_t in host byte order 85 | * @return n in network byte order 86 | */ 87 | u32_t 88 | lwip_htonl(u32_t n) 89 | { 90 | return ((n & 0xff) << 24) | 91 | ((n & 0xff00) << 8) | 92 | ((n & 0xff0000UL) >> 8) | 93 | ((n & 0xff000000UL) >> 24); 94 | } 95 | 96 | /** 97 | * Convert an u32_t from network- to host byte order. 98 | * 99 | * @param n u32_t in network byte order 100 | * @return n in host byte order 101 | */ 102 | u32_t 103 | lwip_ntohl(u32_t n) 104 | { 105 | return lwip_htonl(n); 106 | } 107 | 108 | #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ 109 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/netif/fifo.c: -------------------------------------------------------------------------------- 1 | /* Author: Magnus Ivarsson */ 2 | 3 | /* ---------------------------------------------- */ 4 | /* --- fifo 4 unix ------------------------------ */ 5 | /* ---------------------------------------------- */ 6 | #include "netif/fifo.h" 7 | #include "lwip/debug.h" 8 | #include "lwip/def.h" 9 | #include "lwip/sys.h" 10 | #include "lwip/arch.h" 11 | #include 12 | 13 | #ifndef TRUE 14 | #define TRUE 1 15 | #endif 16 | #ifndef FALSE 17 | #define FALSE 0 18 | #endif 19 | 20 | 21 | u8_t fifoGet(fifo_t * fifo) 22 | { 23 | u8_t c; 24 | 25 | sys_sem_wait(&fifo->sem); /* enter critical section */ 26 | 27 | if (fifo->dataslot == fifo->emptyslot) 28 | { 29 | fifo->getWaiting = TRUE; /* tell putFifo to signal us when data is available */ 30 | sys_sem_signal(&fifo->sem); /* leave critical section (allow input from serial port..) */ 31 | sys_sem_wait(&fifo->getSem); /* wait 4 data */ 32 | sys_sem_wait(&fifo->sem); /* reenter critical section */ 33 | } 34 | 35 | c = fifo->data[fifo->dataslot++]; 36 | fifo->len--; 37 | 38 | if (fifo->dataslot == FIFOSIZE) 39 | { 40 | fifo->dataslot = 0; 41 | } 42 | sys_sem_signal(&fifo->sem); /* leave critical section */ 43 | return c; 44 | } 45 | 46 | 47 | s16_t fifoGetNonBlock(fifo_t * fifo) 48 | { 49 | u16_t c; 50 | 51 | sys_sem_wait(&fifo->sem); /* enter critical section */ 52 | 53 | if (fifo->dataslot == fifo->emptyslot) 54 | { 55 | /* empty fifo */ 56 | c = -1; 57 | } 58 | else 59 | { 60 | c = fifo->data[fifo->dataslot++]; 61 | fifo->len--; 62 | 63 | if (fifo->dataslot == FIFOSIZE) 64 | { 65 | fifo->dataslot = 0; 66 | } 67 | } 68 | sys_sem_signal(&fifo->sem); /* leave critical section */ 69 | return c; 70 | } 71 | 72 | 73 | void fifoPut(fifo_t * fifo, int fd) 74 | { 75 | /* FIXME: mutex around struct data.. */ 76 | int cnt=0; 77 | 78 | sys_sem_wait(&fifo->sem ); /* enter critical */ 79 | 80 | LWIP_DEBUGF( SIO_FIFO_DEBUG,("fifoput: len%d dat%d empt%d --> ", fifo->len, fifo->dataslot, fifo->emptyslot ) ); 81 | 82 | if ( fifo->emptyslot < fifo->dataslot ) 83 | { 84 | cnt = read( fd, &fifo->data[fifo->emptyslot], fifo->dataslot - fifo->emptyslot ); 85 | } 86 | else 87 | { 88 | cnt = read( fd, &fifo->data[fifo->emptyslot], FIFOSIZE-fifo->emptyslot ); 89 | } 90 | fifo->emptyslot += cnt; 91 | fifo->len += cnt; 92 | 93 | LWIP_DEBUGF( SIO_FIFO_DEBUG,("len%d dat%d empt%d\n", fifo->len, fifo->dataslot, fifo->emptyslot ) ); 94 | 95 | if ( fifo->len > FIFOSIZE ) 96 | { 97 | printf( "ERROR: fifo overrun detected len=%d, flushing\n", fifo->len ); 98 | fifo->dataslot = 0; 99 | fifo->emptyslot = 0; 100 | fifo->len = 0; 101 | } 102 | 103 | if ( fifo->emptyslot == FIFOSIZE ) 104 | { 105 | fifo->emptyslot = 0; 106 | LWIP_DEBUGF( SIO_FIFO_DEBUG, ("(WRAP) ") ); 107 | 108 | sys_sem_signal(&fifo->sem ); /* leave critical */ 109 | fifoPut( fifo, fd ); 110 | return; 111 | } 112 | if ( fifo->getWaiting ) 113 | { 114 | fifo->getWaiting = FALSE; 115 | sys_sem_signal(&fifo->getSem ); 116 | } 117 | 118 | sys_sem_signal(&fifo->sem ); /* leave critical */ 119 | return; 120 | } 121 | 122 | 123 | void fifoInit(fifo_t * fifo) 124 | { 125 | fifo->dataslot = 0; 126 | fifo->emptyslot = 0; 127 | fifo->len = 0; 128 | if(sys_sem_new(&fifo->sem, 1) != ERR_OK) { /* critical section 1=free to enter */ 129 | LWIP_ASSERT("Failed to create semaphore", 0); 130 | } 131 | if(sys_sem_new(&fifo->getSem, 0) != ERR_OK) { /* 0 = no one waiting */ 132 | LWIP_ASSERT("Failed to create semaphore", 0); 133 | } 134 | fifo->getWaiting = FALSE; 135 | } 136 | -------------------------------------------------------------------------------- /src/include/ipv6/lwip/ip6_frag.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 fragmentation and reassembly. 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_IP6_FRAG_H__ 42 | #define __LWIP_IP6_FRAG_H__ 43 | 44 | #include "lwip/opt.h" 45 | #include "lwip/pbuf.h" 46 | #include "lwip/ip6_addr.h" 47 | #include "lwip/netif.h" 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | 54 | #if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ 55 | 56 | /* The IPv6 reassembly timer interval in milliseconds. */ 57 | #define IP6_REASS_TMR_INTERVAL 1000 58 | 59 | /* IPv6 reassembly helper struct. 60 | * This is exported because memp needs to know the size. 61 | */ 62 | struct ip6_reassdata { 63 | struct ip6_reassdata *next; 64 | struct pbuf *p; 65 | struct ip6_hdr * iphdr; 66 | u32_t identification; 67 | u16_t datagram_len; 68 | u8_t nexth; 69 | u8_t timer; 70 | }; 71 | 72 | #define ip6_reass_init() /* Compatibility define */ 73 | void ip6_reass_tmr(void); 74 | struct pbuf * ip6_reass(struct pbuf *p); 75 | 76 | #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ 77 | 78 | #if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */ 79 | 80 | /** A custom pbuf that holds a reference to another pbuf, which is freed 81 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 82 | * that points into the original pbuf. */ 83 | #ifndef __LWIP_PBUF_CUSTOM_REF__ 84 | #define __LWIP_PBUF_CUSTOM_REF__ 85 | struct pbuf_custom_ref { 86 | /** 'base class' */ 87 | struct pbuf_custom pc; 88 | /** pointer to the original pbuf that is referenced */ 89 | struct pbuf *original; 90 | }; 91 | #endif /* __LWIP_PBUF_CUSTOM_REF__ */ 92 | 93 | err_t ip6_frag(struct pbuf *p, struct netif *netif, ip6_addr_t *dest); 94 | 95 | #endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ 96 | 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __LWIP_IP6_FRAG_H__ */ 103 | -------------------------------------------------------------------------------- /src/include/lwip/timers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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 | * Simon Goldschmidt 31 | * 32 | */ 33 | #ifndef __LWIP_TIMERS_H__ 34 | #define __LWIP_TIMERS_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | /* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ 39 | #define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) 40 | 41 | #if LWIP_TIMERS 42 | 43 | #include "lwip/err.h" 44 | #if !NO_SYS 45 | #include "lwip/sys.h" 46 | #endif 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #ifndef LWIP_DEBUG_TIMERNAMES 53 | #ifdef LWIP_DEBUG 54 | #define LWIP_DEBUG_TIMERNAMES SYS_DEBUG 55 | #else /* LWIP_DEBUG */ 56 | #define LWIP_DEBUG_TIMERNAMES 0 57 | #endif /* LWIP_DEBUG*/ 58 | #endif 59 | 60 | /** Function prototype for a timeout callback function. Register such a function 61 | * using sys_timeout(). 62 | * 63 | * @param arg Additional argument to pass to the function - set up by sys_timeout() 64 | */ 65 | typedef void (* sys_timeout_handler)(void *arg); 66 | 67 | struct sys_timeo { 68 | struct sys_timeo *next; 69 | u32_t time; 70 | sys_timeout_handler h; 71 | void *arg; 72 | #if LWIP_DEBUG_TIMERNAMES 73 | const char* handler_name; 74 | #endif /* LWIP_DEBUG_TIMERNAMES */ 75 | }; 76 | 77 | void sys_timeouts_init(void); 78 | 79 | #if LWIP_DEBUG_TIMERNAMES 80 | void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); 81 | #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) 82 | #else /* LWIP_DEBUG_TIMERNAMES */ 83 | void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); 84 | #endif /* LWIP_DEBUG_TIMERNAMES */ 85 | 86 | void sys_untimeout(sys_timeout_handler handler, void *arg); 87 | #if NO_SYS 88 | void sys_check_timeouts(void); 89 | void sys_restart_timeouts(void); 90 | #else /* NO_SYS */ 91 | void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); 92 | #endif /* NO_SYS */ 93 | 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* LWIP_TIMERS */ 100 | #endif /* __LWIP_TIMERS_H__ */ 101 | -------------------------------------------------------------------------------- /src/include/ipv6/lwip/inet6.h: -------------------------------------------------------------------------------- 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 | #ifndef __LWIP_INET6_H__ 42 | #define __LWIP_INET6_H__ 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_IPV6 && LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/ip6_addr.h" 49 | #include "lwip/def.h" 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** For compatibility with BSD code */ 56 | struct in6_addr { 57 | union { 58 | u8_t u8_addr[16]; 59 | u32_t u32_addr[4]; 60 | } un; 61 | #define s6_addr un.u8_addr 62 | }; 63 | 64 | #define IN6ADDR_ANY_INIT {0,0,0,0} 65 | #define IN6ADDR_LOOPBACK_INIT {0,0,0,PP_HTONL(1)} 66 | 67 | 68 | #define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \ 69 | (target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \ 70 | (target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \ 71 | (target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];} 72 | #define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \ 73 | (target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \ 74 | (target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \ 75 | (target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3];} 76 | /* ATTENTION: the next define only works because both in6_addr and ip6_addr_t are an u32_t[4] effectively! */ 77 | #define inet6_addr_to_ip6addr_p(target_ip6addr_p, source_in6addr) ((target_ip6addr_p) = (ip6_addr_t*)(source_in6addr)) 78 | 79 | /* directly map this to the lwip internal functions */ 80 | #define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr) 81 | #define inet6_ntoa(addr) ip6addr_ntoa((ip6_addr_t*)&(addr)) 82 | #define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((ip6_addr_t*)&(addr), buf, buflen) 83 | 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* LWIP_IPV6 */ 90 | 91 | #endif /* __LWIP_INET6_H__ */ 92 | 93 | -------------------------------------------------------------------------------- /src/include/ipv4/lwip/igmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 CITEL Technologies Ltd. 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 CITEL Technologies Ltd 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 CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' 18 | * AND 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 CITEL TECHNOLOGIES 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 a contribution to the lwIP TCP/IP stack. 30 | * The Swedish Institute of Computer Science and Adam Dunkels 31 | * are specifically granted permission to redistribute this 32 | * source code. 33 | */ 34 | 35 | #ifndef __LWIP_IGMP_H__ 36 | #define __LWIP_IGMP_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/ip_addr.h" 40 | #include "lwip/netif.h" 41 | #include "lwip/pbuf.h" 42 | 43 | #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | 50 | /* IGMP timer */ 51 | #define IGMP_TMR_INTERVAL 100 /* Milliseconds */ 52 | #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) 53 | #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) 54 | 55 | /* MAC Filter Actions, these are passed to a netif's 56 | * igmp_mac_filter callback function. */ 57 | #define IGMP_DEL_MAC_FILTER 0 58 | #define IGMP_ADD_MAC_FILTER 1 59 | 60 | 61 | /** 62 | * igmp group structure - there is 63 | * a list of groups for each interface 64 | * these should really be linked from the interface, but 65 | * if we keep them separate we will not affect the lwip original code 66 | * too much 67 | * 68 | * There will be a group for the all systems group address but this 69 | * will not run the state machine as it is used to kick off reports 70 | * from all the other groups 71 | */ 72 | struct igmp_group { 73 | /** next link */ 74 | struct igmp_group *next; 75 | /** interface on which the group is active */ 76 | struct netif *netif; 77 | /** multicast address */ 78 | ip_addr_t group_address; 79 | /** signifies we were the last person to report */ 80 | u8_t last_reporter_flag; 81 | /** current state of the group */ 82 | u8_t group_state; 83 | /** timer for reporting, negative is OFF */ 84 | u16_t timer; 85 | /** counter of simultaneous uses */ 86 | u8_t use; 87 | }; 88 | 89 | /* Prototypes */ 90 | void igmp_init(void); 91 | err_t igmp_start(struct netif *netif); 92 | err_t igmp_stop(struct netif *netif); 93 | void igmp_report_groups(struct netif *netif); 94 | struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); 95 | void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); 96 | err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); 97 | err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); 98 | void igmp_tmr(void); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* LWIP_IGMP */ 105 | 106 | #endif /* __LWIP_IGMP_H__ */ 107 | -------------------------------------------------------------------------------- /src/include/ipv6/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_MLD6_H__ 44 | #define __LWIP_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 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | struct mld_group { 59 | /** next link */ 60 | struct mld_group *next; 61 | /** interface on which the group is active */ 62 | struct netif *netif; 63 | /** multicast address */ 64 | ip6_addr_t group_address; 65 | /** signifies we were the last person to report */ 66 | u8_t last_reporter_flag; 67 | /** current state of the group */ 68 | u8_t group_state; 69 | /** timer for reporting */ 70 | u16_t timer; 71 | /** counter of simultaneous uses */ 72 | u8_t use; 73 | }; 74 | 75 | /** Multicast listener report/query/done message header. */ 76 | #ifdef PACK_STRUCT_USE_INCLUDES 77 | # include "arch/bpstruct.h" 78 | #endif 79 | PACK_STRUCT_BEGIN 80 | struct mld_header { 81 | PACK_STRUCT_FIELD(u8_t type); 82 | PACK_STRUCT_FIELD(u8_t code); 83 | PACK_STRUCT_FIELD(u16_t chksum); 84 | PACK_STRUCT_FIELD(u16_t max_resp_delay); 85 | PACK_STRUCT_FIELD(u16_t reserved); 86 | PACK_STRUCT_FIELD(ip6_addr_p_t multicast_address); 87 | /* Options follow. */ 88 | } PACK_STRUCT_STRUCT; 89 | PACK_STRUCT_END 90 | #ifdef PACK_STRUCT_USE_INCLUDES 91 | # include "arch/epstruct.h" 92 | #endif 93 | 94 | #define MLD6_TMR_INTERVAL 100 /* Milliseconds */ 95 | 96 | /* MAC Filter Actions, these are passed to a netif's 97 | * mld_mac_filter callback function. */ 98 | #define MLD6_DEL_MAC_FILTER 0 99 | #define MLD6_ADD_MAC_FILTER 1 100 | 101 | 102 | #define mld6_init() /* TODO should we init tables? */ 103 | err_t mld6_stop(struct netif *netif); 104 | void mld6_report_groups(struct netif *netif); 105 | void mld6_tmr(void); 106 | struct mld_group *mld6_lookfor_group(struct netif *ifp, ip6_addr_t *addr); 107 | void mld6_input(struct pbuf *p, struct netif *inp); 108 | err_t mld6_joingroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr); 109 | err_t mld6_leavegroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr); 110 | 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* LWIP_IPV6_MLD && LWIP_IPV6 */ 117 | 118 | #endif /* __LWIP_MLD6_H__ */ 119 | -------------------------------------------------------------------------------- /src/include/lwip/def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_DEF_H__ 33 | #define __LWIP_DEF_H__ 34 | 35 | /* arch.h might define NULL already */ 36 | #include "lwip/arch.h" 37 | #include "lwip/opt.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) 44 | #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) 45 | 46 | #ifndef NULL 47 | #define NULL ((void *)0) 48 | #endif 49 | 50 | /* Endianess-optimized shifting of two u8_t to create one u16_t */ 51 | #if BYTE_ORDER == LITTLE_ENDIAN 52 | #define LWIP_MAKE_U16(a, b) ((a << 8) | b) 53 | #else 54 | #define LWIP_MAKE_U16(a, b) ((b << 8) | a) 55 | #endif 56 | 57 | #ifndef LWIP_PLATFORM_BYTESWAP 58 | #define LWIP_PLATFORM_BYTESWAP 0 59 | #endif 60 | 61 | #ifndef LWIP_PREFIX_BYTEORDER_FUNCS 62 | /* workaround for naming collisions on some platforms */ 63 | 64 | #ifdef htons 65 | #undef htons 66 | #endif /* htons */ 67 | #ifdef htonl 68 | #undef htonl 69 | #endif /* htonl */ 70 | #ifdef ntohs 71 | #undef ntohs 72 | #endif /* ntohs */ 73 | #ifdef ntohl 74 | #undef ntohl 75 | #endif /* ntohl */ 76 | 77 | #define htons(x) lwip_htons(x) 78 | #define ntohs(x) lwip_ntohs(x) 79 | #define htonl(x) lwip_htonl(x) 80 | #define ntohl(x) lwip_ntohl(x) 81 | #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ 82 | 83 | #if BYTE_ORDER == BIG_ENDIAN 84 | #define lwip_htons(x) (x) 85 | #define lwip_ntohs(x) (x) 86 | #define lwip_htonl(x) (x) 87 | #define lwip_ntohl(x) (x) 88 | #define PP_HTONS(x) (x) 89 | #define PP_NTOHS(x) (x) 90 | #define PP_HTONL(x) (x) 91 | #define PP_NTOHL(x) (x) 92 | #else /* BYTE_ORDER != BIG_ENDIAN */ 93 | #if LWIP_PLATFORM_BYTESWAP 94 | #define lwip_htons(x) LWIP_PLATFORM_HTONS(x) 95 | #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) 96 | #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) 97 | #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) 98 | #else /* LWIP_PLATFORM_BYTESWAP */ 99 | u16_t lwip_htons(u16_t x); 100 | u16_t lwip_ntohs(u16_t x); 101 | u32_t lwip_htonl(u32_t x); 102 | u32_t lwip_ntohl(u32_t x); 103 | #endif /* LWIP_PLATFORM_BYTESWAP */ 104 | 105 | /* These macros should be calculated by the preprocessor and are used 106 | with compile-time constants only (so that there is no little-endian 107 | overhead at runtime). */ 108 | #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) 109 | #define PP_NTOHS(x) PP_HTONS(x) 110 | #define PP_HTONL(x) ((((x) & 0xff) << 24) | \ 111 | (((x) & 0xff00) << 8) | \ 112 | (((x) & 0xff0000UL) >> 8) | \ 113 | (((x) & 0xff000000UL) >> 24)) 114 | #define PP_NTOHL(x) PP_HTONL(x) 115 | 116 | #endif /* BYTE_ORDER == BIG_ENDIAN */ 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __LWIP_DEF_H__ */ 123 | 124 | -------------------------------------------------------------------------------- /src/include/lwip/memp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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 | #ifndef __LWIP_MEMP_H__ 34 | #define __LWIP_MEMP_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ 43 | typedef enum { 44 | #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, 45 | #include "lwip/memp_std.h" 46 | MEMP_MAX 47 | } memp_t; 48 | 49 | #if MEM_USE_POOLS 50 | /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ 51 | typedef enum { 52 | /* Get the first (via: 53 | MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ 54 | MEMP_POOL_HELPER_FIRST = ((u8_t) 55 | #define LWIP_MEMPOOL(name,num,size,desc) 56 | #define LWIP_MALLOC_MEMPOOL_START 1 57 | #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 58 | #define LWIP_MALLOC_MEMPOOL_END 59 | #include "lwip/memp_std.h" 60 | ) , 61 | /* Get the last (via: 62 | MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ 63 | MEMP_POOL_HELPER_LAST = ((u8_t) 64 | #define LWIP_MEMPOOL(name,num,size,desc) 65 | #define LWIP_MALLOC_MEMPOOL_START 66 | #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * 67 | #define LWIP_MALLOC_MEMPOOL_END 1 68 | #include "lwip/memp_std.h" 69 | ) 70 | } memp_pool_helper_t; 71 | 72 | /* The actual start and stop values are here (cast them over) 73 | We use this helper type and these defines so we can avoid using const memp_t values */ 74 | #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) 75 | #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) 76 | #endif /* MEM_USE_POOLS */ 77 | 78 | #if MEMP_MEM_MALLOC || MEM_USE_POOLS 79 | extern const u16_t memp_sizes[MEMP_MAX]; 80 | #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ 81 | 82 | #if MEMP_MEM_MALLOC 83 | 84 | #include "mem.h" 85 | 86 | #define memp_init() 87 | #define memp_malloc(type) mem_malloc(memp_sizes[type]) 88 | #define memp_free(type, mem) mem_free(mem) 89 | 90 | #else /* MEMP_MEM_MALLOC */ 91 | 92 | #if MEM_USE_POOLS 93 | /** This structure is used to save the pool one element came from. */ 94 | struct memp_malloc_helper 95 | { 96 | memp_t poolnr; 97 | }; 98 | #endif /* MEM_USE_POOLS */ 99 | 100 | void memp_init(void); 101 | 102 | #if MEMP_OVERFLOW_CHECK 103 | void *memp_malloc_fn(memp_t type, const char* file, const int line); 104 | #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) 105 | #else 106 | void *memp_malloc(memp_t type); 107 | #endif 108 | void memp_free(memp_t type, void *mem); 109 | 110 | #endif /* MEMP_MEM_MALLOC */ 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* __LWIP_MEMP_H__ */ 117 | -------------------------------------------------------------------------------- /src/include/lwip/snmp_asn1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Abstract Syntax Notation One (ISO 8824, 8825) codec. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. 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 | * Author: Christiaan Simons 33 | */ 34 | 35 | #ifndef __LWIP_SNMP_ASN1_H__ 36 | #define __LWIP_SNMP_ASN1_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/err.h" 40 | #include "lwip/pbuf.h" 41 | #include "lwip/snmp.h" 42 | 43 | #if LWIP_SNMP 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ 50 | #define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ 51 | #define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ 52 | 53 | #define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ 54 | #define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ 55 | 56 | /* universal tags */ 57 | #define SNMP_ASN1_INTEG 2 58 | #define SNMP_ASN1_OC_STR 4 59 | #define SNMP_ASN1_NUL 5 60 | #define SNMP_ASN1_OBJ_ID 6 61 | #define SNMP_ASN1_SEQ 16 62 | 63 | /* application specific (SNMP) tags */ 64 | #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ 65 | #define SNMP_ASN1_COUNTER 1 /* u32_t */ 66 | #define SNMP_ASN1_GAUGE 2 /* u32_t */ 67 | #define SNMP_ASN1_TIMETICKS 3 /* u32_t */ 68 | #define SNMP_ASN1_OPAQUE 4 /* octet string */ 69 | 70 | /* context specific (SNMP) tags */ 71 | #define SNMP_ASN1_PDU_GET_REQ 0 72 | #define SNMP_ASN1_PDU_GET_NEXT_REQ 1 73 | #define SNMP_ASN1_PDU_GET_RESP 2 74 | #define SNMP_ASN1_PDU_SET_REQ 3 75 | #define SNMP_ASN1_PDU_TRAP 4 76 | 77 | err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); 78 | err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); 79 | err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); 80 | err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); 81 | err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); 82 | err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); 83 | 84 | void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); 85 | void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); 86 | void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); 87 | void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); 88 | err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); 89 | err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); 90 | err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); 91 | err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); 92 | err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); 93 | err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* LWIP_SNMP */ 100 | 101 | #endif /* __LWIP_SNMP_ASN1_H__ */ 102 | -------------------------------------------------------------------------------- /src/netif/ppp/auth.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * auth.h - PPP Authentication and phase control header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original derived from BSD pppd.h. 32 | *****************************************************************************/ 33 | /* 34 | * pppd.h - PPP daemon global declarations. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | * 51 | */ 52 | 53 | #ifndef AUTH_H 54 | #define AUTH_H 55 | 56 | /*********************** 57 | *** PUBLIC FUNCTIONS *** 58 | ***********************/ 59 | 60 | /* we are starting to use the link */ 61 | void link_required (int); 62 | 63 | /* we are finished with the link */ 64 | void link_terminated (int); 65 | 66 | /* the LCP layer has left the Opened state */ 67 | void link_down (int); 68 | 69 | /* the link is up; authenticate now */ 70 | void link_established (int); 71 | 72 | /* a network protocol has come up */ 73 | void np_up (int, u16_t); 74 | 75 | /* a network protocol has gone down */ 76 | void np_down (int, u16_t); 77 | 78 | /* a network protocol no longer needs link */ 79 | void np_finished (int, u16_t); 80 | 81 | /* peer failed to authenticate itself */ 82 | void auth_peer_fail (int, u16_t); 83 | 84 | /* peer successfully authenticated itself */ 85 | void auth_peer_success (int, u16_t, char *, int); 86 | 87 | /* we failed to authenticate ourselves */ 88 | void auth_withpeer_fail (int, u16_t); 89 | 90 | /* we successfully authenticated ourselves */ 91 | void auth_withpeer_success (int, u16_t); 92 | 93 | /* check authentication options supplied */ 94 | void auth_check_options (void); 95 | 96 | /* check what secrets we have */ 97 | void auth_reset (int); 98 | 99 | /* Check peer-supplied username/password */ 100 | u_char check_passwd (int, char *, int, char *, int, char **, int *); 101 | 102 | /* get "secret" for chap */ 103 | int get_secret (int, char *, char *, char *, int *, int); 104 | 105 | /* check if IP address is authorized */ 106 | int auth_ip_addr (int, u32_t); 107 | 108 | /* check if IP address is unreasonable */ 109 | int bad_ip_adrs (u32_t); 110 | 111 | #endif /* AUTH_H */ 112 | -------------------------------------------------------------------------------- /src/include/lwip/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "lwip/arch.h" 36 | #include "lwip/opt.h" 37 | 38 | /** lower two bits indicate debug level 39 | * - 0 all 40 | * - 1 warning 41 | * - 2 serious 42 | * - 3 severe 43 | */ 44 | #define LWIP_DBG_LEVEL_ALL 0x00 45 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 46 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 47 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 48 | #define LWIP_DBG_LEVEL_SEVERE 0x03 49 | #define LWIP_DBG_MASK_LEVEL 0x03 50 | 51 | /** flag for LWIP_DEBUGF to enable that debug message */ 52 | #define LWIP_DBG_ON 0x80U 53 | /** flag for LWIP_DEBUGF to disable that debug message */ 54 | #define LWIP_DBG_OFF 0x00U 55 | 56 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 57 | #define LWIP_DBG_TRACE 0x40U 58 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 59 | #define LWIP_DBG_STATE 0x20U 60 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 61 | #define LWIP_DBG_FRESH 0x10U 62 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 63 | #define LWIP_DBG_HALT 0x08U 64 | 65 | #ifndef LWIP_NOASSERT 66 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 67 | LWIP_PLATFORM_ASSERT(message); } while(0) 68 | #else /* LWIP_NOASSERT */ 69 | #define LWIP_ASSERT(message, assertion) 70 | #endif /* LWIP_NOASSERT */ 71 | 72 | /** if "expression" isn't true, then print "message" and execute "handler" expression */ 73 | #ifndef LWIP_ERROR 74 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 75 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 76 | #endif /* LWIP_ERROR */ 77 | 78 | #ifdef LWIP_DEBUG 79 | /** print debug message only if debug message type is enabled... 80 | * AND is of correct type AND is at least LWIP_DBG_LEVEL 81 | */ 82 | #define LWIP_DEBUGF(debug, message) do { \ 83 | if ( \ 84 | ((debug) & LWIP_DBG_ON) && \ 85 | ((debug) & LWIP_DBG_TYPES_ON) && \ 86 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 87 | LWIP_PLATFORM_DIAG(message); \ 88 | if ((debug) & LWIP_DBG_HALT) { \ 89 | while(1); \ 90 | } \ 91 | } \ 92 | } while(0) 93 | 94 | #else /* LWIP_DEBUG */ 95 | #define LWIP_DEBUGF(debug, message) 96 | #endif /* LWIP_DEBUG */ 97 | 98 | #endif /* __LWIP_DEBUG_H__ */ 99 | 100 | -------------------------------------------------------------------------------- /test/unit/core/test_pbuf.c: -------------------------------------------------------------------------------- 1 | #include "test_pbuf.h" 2 | 3 | #include "lwip/pbuf.h" 4 | #include "lwip/stats.h" 5 | 6 | #if !LWIP_STATS || !MEM_STATS ||!MEMP_STATS 7 | #error "This tests needs MEM- and MEMP-statistics enabled" 8 | #endif 9 | #if LWIP_DNS 10 | #error "This test needs DNS turned off (as it mallocs on init)" 11 | #endif 12 | #if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !LWIP_WND_SCALE 13 | #error "This test needs TCP OOSEQ queueing and window scaling enabled" 14 | #endif 15 | 16 | /* Setups/teardown functions */ 17 | 18 | static void 19 | pbuf_setup(void) 20 | { 21 | } 22 | 23 | static void 24 | pbuf_teardown(void) 25 | { 26 | } 27 | 28 | 29 | #define TESTBUFSIZE_1 65535 30 | #define TESTBUFSIZE_2 65530 31 | #define TESTBUFSIZE_3 50050 32 | static u8_t testbuf_1[TESTBUFSIZE_1]; 33 | static u8_t testbuf_1a[TESTBUFSIZE_1]; 34 | static u8_t testbuf_2[TESTBUFSIZE_2]; 35 | static u8_t testbuf_2a[TESTBUFSIZE_2]; 36 | static u8_t testbuf_3[TESTBUFSIZE_3]; 37 | static u8_t testbuf_3a[TESTBUFSIZE_3]; 38 | 39 | /* Test functions */ 40 | 41 | /** Call pbuf_copy on a pbuf with zero length */ 42 | START_TEST(test_pbuf_copy_zero_pbuf) 43 | { 44 | struct pbuf *p1, *p2, *p3; 45 | err_t err; 46 | LWIP_UNUSED_ARG(_i); 47 | 48 | fail_unless(lwip_stats.mem.used == 0); 49 | fail_unless(lwip_stats.memp[MEMP_PBUF_POOL].used == 0); 50 | 51 | p1 = pbuf_alloc(PBUF_RAW, 1024, PBUF_RAM); 52 | fail_unless(p1 != NULL); 53 | fail_unless(p1->ref == 1); 54 | 55 | p2 = pbuf_alloc(PBUF_RAW, 2, PBUF_POOL); 56 | fail_unless(p2 != NULL); 57 | fail_unless(p2->ref == 1); 58 | p2->len = p2->tot_len = 0; 59 | 60 | pbuf_cat(p1, p2); 61 | fail_unless(p1->ref == 1); 62 | fail_unless(p2->ref == 1); 63 | 64 | p3 = pbuf_alloc(PBUF_RAW, p1->tot_len, PBUF_POOL); 65 | err = pbuf_copy(p3, p1); 66 | fail_unless(err == ERR_VAL); 67 | 68 | pbuf_free(p1); 69 | pbuf_free(p3); 70 | fail_unless(lwip_stats.mem.used == 0); 71 | 72 | fail_unless(lwip_stats.mem.used == 0); 73 | fail_unless(lwip_stats.memp[MEMP_PBUF_POOL].used == 0); 74 | } 75 | END_TEST 76 | 77 | START_TEST(test_pbuf_split_64k_on_small_pbufs) 78 | { 79 | struct pbuf *p, *rest=NULL; 80 | LWIP_UNUSED_ARG(_i); 81 | 82 | p = pbuf_alloc(PBUF_RAW, 1, PBUF_POOL); 83 | pbuf_split_64k(p, &rest); 84 | fail_unless(p->tot_len == 1); 85 | pbuf_free(p); 86 | } 87 | END_TEST 88 | 89 | START_TEST(test_pbuf_queueing_bigger_than_64k) 90 | { 91 | int i; 92 | err_t err; 93 | struct pbuf *p1, *p2, *p3, *rest2=NULL, *rest3=NULL; 94 | LWIP_UNUSED_ARG(_i); 95 | 96 | for(i = 0; i < TESTBUFSIZE_1; i++) 97 | testbuf_1[i] = rand(); 98 | for(i = 0; i < TESTBUFSIZE_2; i++) 99 | testbuf_2[i] = rand(); 100 | for(i = 0; i < TESTBUFSIZE_3; i++) 101 | testbuf_3[i] = rand(); 102 | 103 | p1 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_1, PBUF_POOL); 104 | fail_unless(p1 != NULL); 105 | p2 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_2, PBUF_POOL); 106 | fail_unless(p2 != NULL); 107 | p3 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_3, PBUF_POOL); 108 | fail_unless(p3 != NULL); 109 | err = pbuf_take(p1, testbuf_1, TESTBUFSIZE_1); 110 | fail_unless(err == ERR_OK); 111 | err = pbuf_take(p2, testbuf_2, TESTBUFSIZE_2); 112 | fail_unless(err == ERR_OK); 113 | err = pbuf_take(p3, testbuf_3, TESTBUFSIZE_3); 114 | fail_unless(err == ERR_OK); 115 | 116 | pbuf_cat(p1, p2); 117 | pbuf_cat(p1, p3); 118 | 119 | pbuf_split_64k(p1, &rest2); 120 | fail_unless(p1->tot_len == TESTBUFSIZE_1); 121 | fail_unless(rest2->tot_len == (u16_t)((TESTBUFSIZE_2+TESTBUFSIZE_3) & 0xFFFF)); 122 | pbuf_split_64k(rest2, &rest3); 123 | fail_unless(rest2->tot_len == TESTBUFSIZE_2); 124 | fail_unless(rest3->tot_len == TESTBUFSIZE_3); 125 | 126 | pbuf_copy_partial(p1, testbuf_1a, TESTBUFSIZE_1, 0); 127 | pbuf_copy_partial(rest2, testbuf_2a, TESTBUFSIZE_2, 0); 128 | pbuf_copy_partial(rest3, testbuf_3a, TESTBUFSIZE_3, 0); 129 | for(i = 0; i < TESTBUFSIZE_1; i++) 130 | fail_unless(testbuf_1[i] == testbuf_1a[i]); 131 | for(i = 0; i < TESTBUFSIZE_2; i++) 132 | fail_unless(testbuf_2[i] == testbuf_2a[i]); 133 | for(i = 0; i < TESTBUFSIZE_3; i++) 134 | fail_unless(testbuf_3[i] == testbuf_3a[i]); 135 | 136 | pbuf_free(p1); 137 | pbuf_free(rest2); 138 | pbuf_free(rest3); 139 | } 140 | END_TEST 141 | 142 | /** Create the suite including all tests for this module */ 143 | Suite * 144 | pbuf_suite(void) 145 | { 146 | testfunc tests[] = { 147 | TESTFUNC(test_pbuf_copy_zero_pbuf), 148 | TESTFUNC(test_pbuf_split_64k_on_small_pbufs), 149 | TESTFUNC(test_pbuf_queueing_bigger_than_64k) 150 | }; 151 | return create_suite("PBUF", tests, sizeof(tests)/sizeof(testfunc), pbuf_setup, pbuf_teardown); 152 | } 153 | -------------------------------------------------------------------------------- /src/include/lwip/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_MEM_H__ 33 | #define __LWIP_MEM_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #if MEM_LIBC_MALLOC 42 | 43 | #include /* for size_t */ 44 | 45 | typedef size_t mem_size_t; 46 | #define MEM_SIZE_F SZT_F 47 | 48 | /* aliases for C library malloc() */ 49 | #define mem_init() 50 | /* in case C library malloc() needs extra protection, 51 | * allow these defines to be overridden. 52 | */ 53 | #ifndef mem_free 54 | #define mem_free free 55 | #endif 56 | #ifndef mem_malloc 57 | #define mem_malloc malloc 58 | #endif 59 | #ifndef mem_calloc 60 | #define mem_calloc calloc 61 | #endif 62 | /* Since there is no C library allocation function to shrink memory without 63 | moving it, define this to nothing. */ 64 | #ifndef mem_trim 65 | #define mem_trim(mem, size) (mem) 66 | #endif 67 | #else /* MEM_LIBC_MALLOC */ 68 | 69 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of 70 | * 65535 leaves some room for alignment... 71 | */ 72 | #if MEM_SIZE > 64000L 73 | typedef u32_t mem_size_t; 74 | #define MEM_SIZE_F U32_F 75 | #else 76 | typedef u16_t mem_size_t; 77 | #define MEM_SIZE_F U16_F 78 | #endif /* MEM_SIZE > 64000 */ 79 | 80 | #if MEM_USE_POOLS 81 | /** mem_init is not used when using pools instead of a heap */ 82 | #define mem_init() 83 | /** mem_trim is not used when using pools instead of a heap: 84 | we can't free part of a pool element and don't want to copy the rest */ 85 | #define mem_trim(mem, size) (mem) 86 | #else /* MEM_USE_POOLS */ 87 | /* lwIP alternative malloc */ 88 | void mem_init(void); 89 | void *mem_trim(void *mem, mem_size_t size); 90 | #endif /* MEM_USE_POOLS */ 91 | void *mem_malloc(mem_size_t size); 92 | void *mem_calloc(mem_size_t count, mem_size_t size); 93 | void mem_free(void *mem); 94 | #endif /* MEM_LIBC_MALLOC */ 95 | 96 | /** Calculate memory size for an aligned buffer - returns the next highest 97 | * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and 98 | * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4). 99 | */ 100 | #ifndef LWIP_MEM_ALIGN_SIZE 101 | #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) 102 | #endif 103 | 104 | /** Calculate safe memory size for an aligned buffer when using an unaligned 105 | * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the 106 | * start (e.g. if buffer is u8_t[] and actual data will be u32_t*) 107 | */ 108 | #ifndef LWIP_MEM_ALIGN_BUFFER 109 | #define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1)) 110 | #endif 111 | 112 | /** Align a memory pointer to the alignment defined by MEM_ALIGNMENT 113 | * so that ADDR % MEM_ALIGNMENT == 0 114 | */ 115 | #ifndef LWIP_MEM_ALIGN 116 | #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) 117 | #endif 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif /* __LWIP_MEM_H__ */ 124 | -------------------------------------------------------------------------------- /src/include/lwip/sio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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 | 30 | /* 31 | * This is the interface to the platform specific serial IO module 32 | * It needs to be implemented by those platforms which need SLIP or PPP 33 | */ 34 | 35 | #ifndef __SIO_H__ 36 | #define __SIO_H__ 37 | 38 | #include "lwip/arch.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* If you want to define sio_fd_t elsewhere or differently, 45 | define this in your cc.h file. */ 46 | #ifndef __sio_fd_t_defined 47 | typedef void * sio_fd_t; 48 | #endif 49 | 50 | /* The following functions can be defined to something else in your cc.h file 51 | or be implemented in your custom sio.c file. */ 52 | 53 | #ifndef sio_open 54 | /** 55 | * Opens a serial device for communication. 56 | * 57 | * @param devnum device number 58 | * @return handle to serial device if successful, NULL otherwise 59 | */ 60 | sio_fd_t sio_open(u8_t devnum); 61 | #endif 62 | 63 | #ifndef sio_send 64 | /** 65 | * Sends a single character to the serial device. 66 | * 67 | * @param c character to send 68 | * @param fd serial device handle 69 | * 70 | * @note This function will block until the character can be sent. 71 | */ 72 | void sio_send(u8_t c, sio_fd_t fd); 73 | #endif 74 | 75 | #ifndef sio_recv 76 | /** 77 | * Receives a single character from the serial device. 78 | * 79 | * @param fd serial device handle 80 | * 81 | * @note This function will block until a character is received. 82 | */ 83 | u8_t sio_recv(sio_fd_t fd); 84 | #endif 85 | 86 | #ifndef sio_read 87 | /** 88 | * Reads from the serial device. 89 | * 90 | * @param fd serial device handle 91 | * @param data pointer to data buffer for receiving 92 | * @param len maximum length (in bytes) of data to receive 93 | * @return number of bytes actually received - may be 0 if aborted by sio_read_abort 94 | * 95 | * @note This function will block until data can be received. The blocking 96 | * can be cancelled by calling sio_read_abort(). 97 | */ 98 | u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); 99 | #endif 100 | 101 | #ifndef sio_tryread 102 | /** 103 | * Tries to read from the serial device. Same as sio_read but returns 104 | * immediately if no data is available and never blocks. 105 | * 106 | * @param fd serial device handle 107 | * @param data pointer to data buffer for receiving 108 | * @param len maximum length (in bytes) of data to receive 109 | * @return number of bytes actually received 110 | */ 111 | u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); 112 | #endif 113 | 114 | #ifndef sio_write 115 | /** 116 | * Writes to the serial device. 117 | * 118 | * @param fd serial device handle 119 | * @param data pointer to data to send 120 | * @param len length (in bytes) of data to send 121 | * @return number of bytes actually sent 122 | * 123 | * @note This function will block until all data can be sent. 124 | */ 125 | u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); 126 | #endif 127 | 128 | #ifndef sio_read_abort 129 | /** 130 | * Aborts a blocking sio_read() call. 131 | * 132 | * @param fd serial device handle 133 | */ 134 | void sio_read_abort(sio_fd_t fd); 135 | #endif 136 | 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | 141 | #endif /* __SIO_H__ */ 142 | -------------------------------------------------------------------------------- /src/include/lwip/netifapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Redistribution and use in source and binary forms, with or without modification, 3 | * are permitted provided that the following conditions are met: 4 | * 5 | * 1. Redistributions of source code must retain the above copyright notice, 6 | * this list of conditions and the following disclaimer. 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, 8 | * this list of conditions and the following disclaimer in the documentation 9 | * and/or other materials provided with the distribution. 10 | * 3. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | * OF SUCH DAMAGE. 23 | * 24 | * This file is part of the lwIP TCP/IP stack. 25 | * 26 | */ 27 | 28 | #ifndef __LWIP_NETIFAPI_H__ 29 | #define __LWIP_NETIFAPI_H__ 30 | 31 | #include "lwip/opt.h" 32 | 33 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ 34 | 35 | #include "lwip/sys.h" 36 | #include "lwip/netif.h" 37 | #include "lwip/dhcp.h" 38 | #include "lwip/autoip.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #if LWIP_MPU_COMPATIBLE 45 | #define NETIFAPI_IPADDR_DEF(m) m 46 | #else /* LWIP_MPU_COMPATIBLE */ 47 | #define NETIFAPI_IPADDR_DEF(m) *m 48 | #endif /* LWIP_MPU_COMPATIBLE */ 49 | 50 | typedef void (*netifapi_void_fn)(struct netif *netif); 51 | typedef err_t (*netifapi_errt_fn)(struct netif *netif); 52 | 53 | struct netifapi_msg_msg { 54 | #if !LWIP_TCPIP_CORE_LOCKING 55 | sys_sem_t sem; 56 | #endif /* !LWIP_TCPIP_CORE_LOCKING */ 57 | err_t err; 58 | struct netif *netif; 59 | union { 60 | struct { 61 | ip_addr_t NETIFAPI_IPADDR_DEF(ipaddr); 62 | ip_addr_t NETIFAPI_IPADDR_DEF(netmask); 63 | ip_addr_t NETIFAPI_IPADDR_DEF(gw); 64 | void *state; 65 | netif_init_fn init; 66 | netif_input_fn input; 67 | } add; 68 | struct { 69 | netifapi_void_fn voidfunc; 70 | netifapi_errt_fn errtfunc; 71 | } common; 72 | } msg; 73 | }; 74 | 75 | struct netifapi_msg { 76 | void (* function)(struct netifapi_msg_msg *msg); 77 | struct netifapi_msg_msg msg; 78 | }; 79 | 80 | 81 | /* API for application */ 82 | err_t netifapi_netif_add ( struct netif *netif, 83 | ip_addr_t *ipaddr, 84 | ip_addr_t *netmask, 85 | ip_addr_t *gw, 86 | void *state, 87 | netif_init_fn init, 88 | netif_input_fn input); 89 | 90 | err_t netifapi_netif_set_addr ( struct netif *netif, 91 | ip_addr_t *ipaddr, 92 | ip_addr_t *netmask, 93 | ip_addr_t *gw ); 94 | 95 | err_t netifapi_netif_common ( struct netif *netif, 96 | netifapi_void_fn voidfunc, 97 | netifapi_errt_fn errtfunc); 98 | 99 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) 100 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) 101 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) 102 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) 103 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) 104 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) 105 | #define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL) 106 | #define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew) 107 | #define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release) 108 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) 109 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* LWIP_NETIF_API */ 116 | 117 | #endif /* __LWIP_NETIFAPI_H__ */ 118 | -------------------------------------------------------------------------------- /src/contrib/ports/unix/netif/list.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 | 34 | 35 | #include 36 | #include 37 | 38 | 39 | /*-----------------------------------------------------------------------------------*/ 40 | struct list * 41 | list_new(int size) 42 | { 43 | struct list *list; 44 | list = (struct list *)malloc(sizeof(struct list)); 45 | list->first = list->last = NULL; 46 | list->size = size; 47 | list->elems = 0; 48 | return list; 49 | } 50 | /*-----------------------------------------------------------------------------------*/ 51 | int 52 | list_push(struct list *list, void *data) 53 | { 54 | struct elem *elem; 55 | 56 | if (list->elems < list->size) { 57 | elem = (struct elem *)malloc(sizeof(struct elem)); 58 | elem->data = data; 59 | elem->next = NULL; 60 | if (list->last != NULL) { 61 | list->last->next = elem; 62 | } 63 | list->last = elem; 64 | if (list->first == NULL) { 65 | list->first = elem; 66 | } 67 | list->elems++; 68 | return 1; 69 | } 70 | return 0; 71 | } 72 | /*-----------------------------------------------------------------------------------*/ 73 | void * 74 | list_pop(struct list *list) 75 | { 76 | struct elem *elem; 77 | void *data; 78 | 79 | if (list->elems > 0) { 80 | elem = list->first; 81 | if (elem == list->last) { 82 | list->last = elem->next; 83 | } 84 | list->first = elem->next; 85 | 86 | list->elems--; 87 | 88 | data = elem->data; 89 | free(elem); 90 | 91 | return data; 92 | } 93 | return NULL; 94 | } 95 | /*-----------------------------------------------------------------------------------*/ 96 | void * 97 | list_first(struct list *list) 98 | { 99 | return list->first; 100 | } 101 | /*-----------------------------------------------------------------------------------*/ 102 | int 103 | list_elems(struct list *list) 104 | { 105 | return list->elems; 106 | } 107 | /*-----------------------------------------------------------------------------------*/ 108 | void 109 | list_delete(struct list *list) 110 | { 111 | while (list_pop(list) != NULL); 112 | free(list); 113 | } 114 | /*-----------------------------------------------------------------------------------*/ 115 | int 116 | list_remove(struct list *list, void *elem) 117 | { 118 | struct elem *e, *p; 119 | 120 | p = NULL; 121 | for(e = list->first; e != NULL; e = e->next) { 122 | if (e->data == elem) { 123 | if (p != NULL) { 124 | p->next = e->next; 125 | } else { 126 | list->first = e->next; 127 | } 128 | if (list->last == e) { 129 | list->last = p; 130 | if (p != NULL) { 131 | p->next = NULL; 132 | } 133 | } 134 | free(e); 135 | list->elems--; 136 | return 1; 137 | } 138 | p = e; 139 | } 140 | return 0; 141 | } 142 | /*-----------------------------------------------------------------------------------*/ 143 | void 144 | list_map(struct list *list, void (* func)(void *arg)) 145 | { 146 | struct elem *e; 147 | 148 | for(e = list->first; e != NULL; e = e->next) { 149 | func(e->data); 150 | } 151 | } 152 | /*-----------------------------------------------------------------------------------*/ 153 | 154 | -------------------------------------------------------------------------------- /src/include/ipv4/lwip/icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_ICMP_H__ 33 | #define __LWIP_ICMP_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | #include "lwip/netif.h" 39 | 40 | #if LWIP_IPV6 && LWIP_ICMP6 41 | #include "lwip/icmp6.h" 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #define ICMP_ER 0 /* echo reply */ 49 | #define ICMP_DUR 3 /* destination unreachable */ 50 | #define ICMP_SQ 4 /* source quench */ 51 | #define ICMP_RD 5 /* redirect */ 52 | #define ICMP_ECHO 8 /* echo */ 53 | #define ICMP_TE 11 /* time exceeded */ 54 | #define ICMP_PP 12 /* parameter problem */ 55 | #define ICMP_TS 13 /* timestamp */ 56 | #define ICMP_TSR 14 /* timestamp reply */ 57 | #define ICMP_IRQ 15 /* information request */ 58 | #define ICMP_IR 16 /* information reply */ 59 | 60 | enum icmp_dur_type { 61 | ICMP_DUR_NET = 0, /* net unreachable */ 62 | ICMP_DUR_HOST = 1, /* host unreachable */ 63 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ 64 | ICMP_DUR_PORT = 3, /* port unreachable */ 65 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 66 | ICMP_DUR_SR = 5 /* source route failed */ 67 | }; 68 | 69 | enum icmp_te_type { 70 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ 71 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ 72 | }; 73 | 74 | #ifdef PACK_STRUCT_USE_INCLUDES 75 | # include "arch/bpstruct.h" 76 | #endif 77 | /** This is the standard ICMP header only that the u32_t data 78 | * is splitted to two u16_t like ICMP echo needs it. 79 | * This header is also used for other ICMP types that do not 80 | * use the data part. 81 | */ 82 | PACK_STRUCT_BEGIN 83 | struct icmp_echo_hdr { 84 | PACK_STRUCT_FIELD(u8_t type); 85 | PACK_STRUCT_FIELD(u8_t code); 86 | PACK_STRUCT_FIELD(u16_t chksum); 87 | PACK_STRUCT_FIELD(u16_t id); 88 | PACK_STRUCT_FIELD(u16_t seqno); 89 | } PACK_STRUCT_STRUCT; 90 | PACK_STRUCT_END 91 | #ifdef PACK_STRUCT_USE_INCLUDES 92 | # include "arch/epstruct.h" 93 | #endif 94 | 95 | #define ICMPH_TYPE(hdr) ((hdr)->type) 96 | #define ICMPH_CODE(hdr) ((hdr)->code) 97 | 98 | /** Combines type and code to an u16_t */ 99 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) 100 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) 101 | 102 | 103 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ 104 | 105 | void icmp_input(struct pbuf *p, struct netif *inp); 106 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); 107 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); 108 | 109 | #endif /* LWIP_ICMP */ 110 | 111 | #if (LWIP_IPV6 && LWIP_ICMP6) 112 | #define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \ 113 | icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \ 114 | icmp_dest_unreach(pbuf, ICMP_DUR_PORT)) 115 | #elif LWIP_ICMP 116 | #define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT) 117 | #else /* (LWIP_IPV6 && LWIP_ICMP6) || LWIP_ICMP*/ 118 | #define icmp_port_unreach(isipv6, pbuf) 119 | #endif /* (LWIP_IPV6 && LWIP_ICMP6) || LWIP_ICMP*/ 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif 124 | 125 | #endif /* __LWIP_ICMP_H__ */ 126 | -------------------------------------------------------------------------------- /src/include/lwip/inet_chksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_INET_CHKSUM_H__ 33 | #define __LWIP_INET_CHKSUM_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #include "lwip/pbuf.h" 38 | #include "lwip/ip_addr.h" 39 | 40 | /** Swap the bytes in an u16_t: much like htons() for little-endian */ 41 | #ifndef SWAP_BYTES_IN_WORD 42 | #if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) 43 | /* little endian and PLATFORM_BYTESWAP defined */ 44 | #define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) 45 | #else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ 46 | /* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ 47 | #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) 48 | #endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ 49 | #endif /* SWAP_BYTES_IN_WORD */ 50 | 51 | /** Split an u32_t in two u16_ts and add them up */ 52 | #ifndef FOLD_U32T 53 | #define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) 54 | #endif 55 | 56 | #if LWIP_CHECKSUM_ON_COPY 57 | /** Function-like macro: same as MEMCPY but returns the checksum of copied data 58 | as u16_t */ 59 | #ifndef LWIP_CHKSUM_COPY 60 | #define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) 61 | #ifndef LWIP_CHKSUM_COPY_ALGORITHM 62 | #define LWIP_CHKSUM_COPY_ALGORITHM 1 63 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 64 | #endif /* LWIP_CHKSUM_COPY */ 65 | #else /* LWIP_CHECKSUM_ON_COPY */ 66 | #define LWIP_CHKSUM_COPY_ALGORITHM 0 67 | #endif /* LWIP_CHECKSUM_ON_COPY */ 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | u16_t inet_chksum(void *dataptr, u16_t len); 74 | u16_t inet_chksum_pbuf(struct pbuf *p); 75 | u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, 76 | ip_addr_t *src, ip_addr_t *dest); 77 | u16_t inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, 78 | u16_t proto_len, u16_t chksum_len, ip_addr_t *src, ip_addr_t *dest); 79 | #if LWIP_CHKSUM_COPY_ALGORITHM 80 | u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); 81 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 82 | 83 | #if LWIP_IPV6 84 | u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, 85 | ip6_addr_t *src, ip6_addr_t *dest); 86 | u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, 87 | u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest); 88 | 89 | #define ipX_chksum_pseudo(isipv6, p, proto, proto_len, src, dest) \ 90 | ((isipv6) ? \ 91 | ip6_chksum_pseudo(p, proto, proto_len, ipX_2_ip6(src), ipX_2_ip6(dest)) :\ 92 | inet_chksum_pseudo(p, proto, proto_len, ipX_2_ip(src), ipX_2_ip(dest))) 93 | #define ipX_chksum_pseudo_partial(isipv6, p, proto, proto_len, chksum_len, src, dest) \ 94 | ((isipv6) ? \ 95 | ip6_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ipX_2_ip6(src), ipX_2_ip6(dest)) :\ 96 | inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ipX_2_ip(src), ipX_2_ip(dest))) 97 | 98 | #else /* LWIP_IPV6 */ 99 | 100 | #define ipX_chksum_pseudo(isipv6, p, proto, proto_len, src, dest) \ 101 | inet_chksum_pseudo(p, proto, proto_len, src, dest) 102 | #define ipX_chksum_pseudo_partial(isipv6, p, proto, proto_len, chksum_len, src, dest) \ 103 | inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, src, dest) 104 | 105 | #endif /* LWIP_IPV6 */ 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | #endif /* __LWIP_INET_H__ */ 112 | 113 | -------------------------------------------------------------------------------- /src/include/lwip/netbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_NETBUF_H__ 33 | #define __LWIP_NETBUF_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | #include "lwip/ip6_addr.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** This netbuf has dest-addr/port set */ 45 | #define NETBUF_FLAG_DESTADDR 0x01 46 | /** This netbuf includes a checksum */ 47 | #define NETBUF_FLAG_CHKSUM 0x02 48 | 49 | struct netbuf { 50 | struct pbuf *p, *ptr; 51 | ipX_addr_t addr; 52 | u16_t port; 53 | #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY 54 | #if LWIP_CHECKSUM_ON_COPY 55 | u8_t flags; 56 | #endif /* LWIP_CHECKSUM_ON_COPY */ 57 | u16_t toport_chksum; 58 | #if LWIP_NETBUF_RECVINFO 59 | ipX_addr_t toaddr; 60 | #endif /* LWIP_NETBUF_RECVINFO */ 61 | #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ 62 | }; 63 | 64 | /* Network buffer functions: */ 65 | struct netbuf * netbuf_new (void); 66 | void netbuf_delete (struct netbuf *buf); 67 | void * netbuf_alloc (struct netbuf *buf, u16_t size); 68 | void netbuf_free (struct netbuf *buf); 69 | err_t netbuf_ref (struct netbuf *buf, 70 | const void *dataptr, u16_t size); 71 | void netbuf_chain (struct netbuf *head, 72 | struct netbuf *tail); 73 | 74 | err_t netbuf_data (struct netbuf *buf, 75 | void **dataptr, u16_t *len); 76 | s8_t netbuf_next (struct netbuf *buf); 77 | void netbuf_first (struct netbuf *buf); 78 | 79 | 80 | #define netbuf_copy_partial(buf, dataptr, len, offset) \ 81 | pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) 82 | #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) 83 | #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) 84 | #define netbuf_len(buf) ((buf)->p->tot_len) 85 | #define netbuf_fromaddr(buf) (ipX_2_ip(&((buf)->addr))) 86 | #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set(ipX_2_ip(&((buf)->addr)), fromaddr) 87 | #define netbuf_fromport(buf) ((buf)->port) 88 | #if LWIP_NETBUF_RECVINFO 89 | #define netbuf_destaddr(buf) (ipX_2_ip(&((buf)->toaddr))) 90 | #define netbuf_set_destaddr(buf, destaddr) ip_addr_set(ipX_2_ip(&((buf)->toaddr)), destaddr) 91 | #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) 92 | #endif /* LWIP_NETBUF_RECVINFO */ 93 | #if LWIP_CHECKSUM_ON_COPY 94 | #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ 95 | (buf)->toport_chksum = chksum; } while(0) 96 | #endif /* LWIP_CHECKSUM_ON_COPY */ 97 | 98 | #if LWIP_IPV6 99 | #define netbuf_fromaddr_ip6(buf) (ipX_2_ip6(&((buf)->addr))) 100 | #define netbuf_set_fromaddr_ip6(buf, fromaddr) ip6_addr_set(ipX_2_ip6(&((buf)->addr)), fromaddr) 101 | #define netbuf_destaddr_ip6(buf) (ipX_2_ip6(&((buf)->toaddr))) 102 | #define netbuf_set_destaddr_ip6(buf, destaddr) ip6_addr_set(ipX_2_ip6(&((buf)->toaddr)), destaddr) 103 | #endif /* LWIP_IPV6 */ 104 | 105 | #define netbuf_fromaddr_ipX(buf) (&((buf)->addr)) 106 | #define netbuf_destaddr_ipX(buf) (&((buf)->toaddr)) 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* __LWIP_NETBUF_H__ */ 113 | -------------------------------------------------------------------------------- /src/include/ipv4/lwip/inet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 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_INET_H__ 33 | #define __LWIP_INET_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/def.h" 37 | #include "lwip/ip_addr.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* If your port already typedef's in_addr_t, define IN_ADDR_T_DEFINED 44 | to prevent this code from redefining it. */ 45 | #if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED) 46 | typedef u32_t in_addr_t; 47 | #endif 48 | /** For compatibility with BSD code */ 49 | struct in_addr { 50 | in_addr_t s_addr; 51 | }; 52 | 53 | /** 255.255.255.255 */ 54 | #define INADDR_NONE IPADDR_NONE 55 | /** 127.0.0.1 */ 56 | #define INADDR_LOOPBACK IPADDR_LOOPBACK 57 | /** 0.0.0.0 */ 58 | #define INADDR_ANY IPADDR_ANY 59 | /** 255.255.255.255 */ 60 | #define INADDR_BROADCAST IPADDR_BROADCAST 61 | 62 | /* Definitions of the bits in an Internet address integer. 63 | 64 | On subnets, host and network parts are found according to 65 | the subnet mask, not these masks. */ 66 | #define IN_CLASSA(a) IP_CLASSA(a) 67 | #define IN_CLASSA_NET IP_CLASSA_NET 68 | #define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT 69 | #define IN_CLASSA_HOST IP_CLASSA_HOST 70 | #define IN_CLASSA_MAX IP_CLASSA_MAX 71 | 72 | #define IN_CLASSB(b) IP_CLASSB(b) 73 | #define IN_CLASSB_NET IP_CLASSB_NET 74 | #define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT 75 | #define IN_CLASSB_HOST IP_CLASSB_HOST 76 | #define IN_CLASSB_MAX IP_CLASSB_MAX 77 | 78 | #define IN_CLASSC(c) IP_CLASSC(c) 79 | #define IN_CLASSC_NET IP_CLASSC_NET 80 | #define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT 81 | #define IN_CLASSC_HOST IP_CLASSC_HOST 82 | #define IN_CLASSC_MAX IP_CLASSC_MAX 83 | 84 | #define IN_CLASSD(d) IP_CLASSD(d) 85 | #define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ 86 | #define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ 87 | #define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ 88 | #define IN_CLASSD_MAX IP_CLASSD_MAX 89 | 90 | #define IN_MULTICAST(a) IP_MULTICAST(a) 91 | 92 | #define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) 93 | #define IN_BADCLASS(a) IP_BADCLASS(a) 94 | 95 | #define IN_LOOPBACKNET IP_LOOPBACKNET 96 | 97 | #ifndef INET_ADDRSTRLEN 98 | #define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX 99 | #endif 100 | #if LWIP_IPV6 101 | #ifndef INET6_ADDRSTRLEN 102 | #define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX 103 | #endif 104 | #endif 105 | 106 | #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) 107 | #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) 108 | /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */ 109 | #define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr)) 110 | 111 | /* directly map this to the lwip internal functions */ 112 | #define inet_addr(cp) ipaddr_addr(cp) 113 | #define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr) 114 | #define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr)) 115 | #define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen) 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* __LWIP_INET_H__ */ 122 | --------------------------------------------------------------------------------