├── .gitignore
├── lwip
├── .cur_version
└── FreeRTOS
│ ├── inc
│ ├── lwippools.h
│ ├── arch
│ │ ├── perf.h
│ │ └── cc.h
│ ├── altera_tse_ethernetif.h
│ ├── ping.h
│ ├── netif
│ │ ├── ppp
│ │ │ ├── pppdebug.h
│ │ │ ├── magic.h
│ │ │ ├── md5.h
│ │ │ ├── chpms.h
│ │ │ ├── randm.h
│ │ │ ├── auth.h
│ │ │ ├── pap.h
│ │ │ └── ipcp.h
│ │ └── slipif.h
│ ├── lwip
│ │ ├── init.h
│ │ ├── err.h
│ │ ├── timers.h
│ │ ├── raw.h
│ │ ├── netifapi.h
│ │ ├── def.h
│ │ ├── memp.h
│ │ ├── snmp_asn1.h
│ │ ├── netbuf.h
│ │ ├── mem.h
│ │ ├── debug.h
│ │ ├── sio.h
│ │ └── netdb.h
│ ├── ipv4
│ │ └── lwip
│ │ │ ├── ip_frag.h
│ │ │ ├── inet_chksum.h
│ │ │ ├── igmp.h
│ │ │ ├── icmp.h
│ │ │ ├── inet.h
│ │ │ └── autoip.h
│ └── os
│ │ └── alt_syscall.h
│ └── src
│ ├── core
│ ├── ipv4
│ │ └── inet.c
│ ├── sys.c
│ └── def.c
│ ├── api
│ ├── err.c
│ └── netifapi.c
│ ├── netif
│ └── ppp
│ │ └── magic.c
│ └── arch
│ ├── alt_lwip_fcntl.c
│ ├── alt_lwip_close.c
│ ├── alt_lwip_write.c
│ └── alt_lwip_read.c
├── altera_nios2
├── altera_nios2_freertos_common.tcl
├── altera_nios2_freertos_sw.tcl
├── altera_nios2_qsys_freertos_sw.tcl
└── FreeRTOS
│ └── src
│ ├── component.mk
│ └── alt_usleep.c
├── freertos
├── build
│ ├── os.sh
│ └── app.mk
├── FreeRTOS
│ ├── inc
│ │ ├── os
│ │ │ ├── alt_hooks.h
│ │ │ ├── alt_sem.h
│ │ │ └── alt_flag.h
│ │ └── priv
│ │ │ └── alt_sem_freertos.h
│ └── src
│ │ ├── alt_env_lock.c
│ │ ├── alt_malloc_lock.c
│ │ └── tse_ethernet_phys.c
└── freertos_systemh_generation.tcl
├── alt-freertos-lwip-install.sh
├── INSTALL
├── alt-freertos-lwip-install.bat
├── freertos_demo
├── template.xml
├── echo_server.c
└── BasicWEB.h
└── README
/.gitignore:
--------------------------------------------------------------------------------
1 | FreeRTOS_src
2 |
--------------------------------------------------------------------------------
/lwip/.cur_version:
--------------------------------------------------------------------------------
1 | lwip-1.4.1.zip
2 |
--------------------------------------------------------------------------------
/altera_nios2/altera_nios2_freertos_common.tcl:
--------------------------------------------------------------------------------
1 | #
2 | # FreeRTOS driver source file listings...
3 | #
4 |
5 | # FreeRTOS-specific C sources
6 | add_sw_property c_source FreeRTOS/src/alt_usleep.c
7 |
8 | # End of file
9 |
--------------------------------------------------------------------------------
/freertos/build/os.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 |
3 | # set -x
4 | #
5 | # Copyright (C) 2005 Altera Corporation
6 | #
7 | # Altera gives unlimited permission to copy, distribute and modify
8 | # this script.
9 |
10 | # This file is included into the auto-generated shell script: generated.sh. It is
11 | # used to provide operating system specific parameters for code download and debug.
12 |
13 | # Symbol names used to follow target thread structures
14 | # TODO incomplete and working...
15 | thread_vars='list:current=*pxCurrentTCB,first=*pxReadyTasksLists[0],id=($T->uxTaskNumber)+1'
16 |
--------------------------------------------------------------------------------
/alt-freertos-lwip-install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # search the altera install path
4 | ALT_PATH="/opt/altera";
5 |
6 | if ! ls "${ALT_PATH}" > /dev/null >2 /dev/null; then
7 | read -p "altera path: [/opt/altera] " ALT_PATH;
8 | fi
9 |
10 | if ! ls "${ALT_PATH}" > /dev/null >2 /dev/null; then
11 | echo "Error: No altera directory found!";
12 | exit 1;
13 | fi
14 |
15 | # get the latest version
16 | ALT_VERSION=`ls "${ALT_PATH}" | tail -1`;
17 |
18 | # build arguments
19 | M_NIOS="${ALT_PATH}/${ALT_VERSION}";
20 | M_INST=`pwd`;
21 |
22 | echo "Launching the Nios II Command Shell, please standby....";
23 |
24 | # launce Nios command shell
25 | "${M_NIOS}/nios2eds/nios2_command_shell.sh" "${M_INST}/alt-freertos-lwip-do-install.sh" "${M_NIOS}" "${M_INST}"
26 |
--------------------------------------------------------------------------------
/INSTALL:
--------------------------------------------------------------------------------
1 | Howto install the new FreeRTOS BSP and the LwIP...?
2 |
3 | Installation instructions:
4 | If you are on a unix system and have wget and curl installed, skip step 1 and 2.
5 |
6 | 1. Download the latest FreeRTOS kernel from www.freertos.org (currently v7.2.0)
7 | 2. Unzip the latest FreeRTOS source into FreeRTOS_src directory.
8 | 3. Execute alt-freertos-lwip-install.bat if your on windows or alt-freertos-lwip-install.sh if your on a unix like system.
9 | 4. Follow the steps provided by the console.
10 |
11 | !!! Note !!!
12 | The LwIP stack uses a modifed version of the socket API! If you want to update the LwIP version you should also apply this patch!
13 | http://savannah.nongnu.org/patch/?7702
14 |
15 | Enjoy!
16 |
17 | Engineering Spirit (c) 2012 http://engineering-spirit.nl/
18 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/lwippools.h:
--------------------------------------------------------------------------------
1 | /* OPTIONAL: Pools to replace heap allocation
2 | * Optional: Pools can be used instead of the heap for mem_malloc. If
3 | * so, these should be defined here, in increasing order according to
4 | * the pool element size.
5 | *
6 | * LWIP_MALLOC_MEMPOOL(number_elements, element_size)
7 | */
8 | #if MEM_USE_POOLS
9 | LWIP_MALLOC_MEMPOOL_START
10 | LWIP_MALLOC_MEMPOOL(20, 256)
11 | LWIP_MALLOC_MEMPOOL(10, 512)
12 | LWIP_MALLOC_MEMPOOL(10, 1536)
13 | LWIP_MALLOC_MEMPOOL_END
14 | #endif /* MEM_USE_POOLS */
15 |
16 | /* Optional: Your custom pools can go here if you would like to use
17 | * lwIP's memory pools for anything else.
18 | */
19 | LWIP_MEMPOOL(SYS_MBOX, 25, 4, "SYS_MBOX")
20 | LWIP_MEMPOOL(SYS_SEM, 25, 4, "SYS_SEM")
21 | LWIP_MEMPOOL(SYS_MUTEX, 25, 4, "SYS_MUTEX")
22 | LWIP_MEMPOOL(SYS_THREAD, 25, 4, "SYS_THREAD")
23 |
--------------------------------------------------------------------------------
/freertos/FreeRTOS/inc/os/alt_hooks.h:
--------------------------------------------------------------------------------
1 | #ifndef __ALT_HOOKS_H__
2 | #define __ALT_HOOKS_H__
3 |
4 | // Provided by Engineering Spirit (c) 2012
5 |
6 | /*
7 | * This file is included by the Altera Vectored Interrpt Controller's
8 | * interrpt funnel assembly code. Only those macros relevant to the funnel
9 | * should be seen by the assembler. The funnel code defines the ALT_ASM_SRC
10 | * macro.
11 | */
12 | #ifndef ALT_ASM_SRC
13 |
14 | #include "FreeRTOS.h"
15 | #include "semphr.h"
16 |
17 | /*
18 | * Semaphores used to protect the heap and environment
19 | */
20 | extern xSemaphoreHandle alt_heapsem;
21 | extern xSemaphoreHandle alt_envsem;
22 |
23 | /*
24 | * Tick handler for FreeRTOS
25 | */
26 | extern void vPortSysTickHandler(void);
27 |
28 | /*
29 | * Thisheader provides definitions for the operating system hooks used by the HAL.
30 | */
31 |
32 | #define ALT_OS_TIME_TICK vPortSysTickHandler
33 | #define ALT_OS_INIT() alt_heapsem = xSemaphoreCreateRecursiveMutex(); \
34 | alt_envsem = xSemaphoreCreateRecursiveMutex();
35 | #define ALT_OS_STOP() // vTaskEndScheduler();
36 |
37 | #define ALT_OS_INT_ENTER() // ....
38 | #define ALT_OS_INT_EXIT() // ....
39 |
40 | #endif /* ALT_ASM_SRC */
41 |
42 | /* These macros are used by the VIC funnel assembly code */
43 | #define ALT_OS_INT_ENTER_ASM //call ....
44 | #define ALT_OS_INT_EXIT_ASM //call ....
45 |
46 | #endif /* __ALT_HOOKS_H__ */
47 |
--------------------------------------------------------------------------------
/alt-freertos-lwip-install.bat:
--------------------------------------------------------------------------------
1 | @ echo off
2 | @ rem save our work directory
3 | @ for /f %%i in ('cd') do set past=%%i
4 |
5 | @ rem check if SOPC_KIT_NIOS2 is set
6 | @ cd %SOPC_KIT_NIOS2% 2> tmp.txt
7 | @ if %errorlevel% equ 0 (
8 | %SOPC_KIT_NIOS2:~0,2%
9 | cd ..
10 | for /f %%i in ('cd') do set nios=%%i
11 | cd "%past%"
12 | %past:~0,2%
13 |
14 | goto exec_nios_shell
15 | )
16 |
17 |
18 | @ rem apperently not.. check if we have QUARTUS_ROOTDIR
19 | @ cd %QUARTUS_ROOTDIR% 2> tmp.txt
20 | @ if %errorlevel% equ 0 (
21 | %QUARTUS_ROOTDIR:~0,2%
22 | cd ..
23 | for /f %%i in ('cd') do set nios=%%i
24 | cd "%past%"
25 | %past:~0,2%
26 |
27 | goto exec_nios_shell
28 | )
29 |
30 | @ rem apperently not.. ask the user for the path...
31 | @ set /p nios="Where is Altera installed? "
32 |
33 | :exec_nios_shell
34 | @ rem get cygwin paths from install directory and quartus toolchain directory
35 | @ for /f %%i in ('%nios%\quartus\bin\cygwin\bin\pwd.exe') do set cyginst=%%i
36 |
37 | @ cd "%nios%" 2> tmp.txt
38 | @ %nios:~0,2%
39 | @ for /f %%i in ('%nios%\quartus\bin\cygwin\bin\pwd.exe') do set cygnios=%%i
40 | @ cd "%past%" 2> tmp.txt
41 | @ %past:~0,2%
42 |
43 | @ del tmp.txt
44 |
45 | @ echo Launching the Nios II Command Shell, please standby....
46 |
47 | @ rem execute the install script for great succes!
48 | @"%nios%\nios2eds\Nios II Command Shell.bat" "%cyginst%/alt-freertos-lwip-do-install.sh" "%cygnios%" "%cyginst%"
--------------------------------------------------------------------------------
/freertos/FreeRTOS/inc/priv/alt_sem_freertos.h:
--------------------------------------------------------------------------------
1 | #ifndef __ALT_SEM_FREERTOS_H__
2 | #define __ALT_SEM_FREERTOS_H__
3 |
4 | // Provided by Engineering Spirit (c) 2012
5 |
6 | /*
7 | * This file provides the FreeRTOS specific functions used to implement the
8 | * macros in alt_sem.h. These functions are simply wrappers for the
9 | * semaphore API.
10 | *
11 | * These functions are considered to be part of the internal implementation of
12 | * the HAL, and should not be called directly by application code or device
13 | * drivers. They are not guaranteed to be preserved in future versions of the
14 | * HAL.
15 | */
16 |
17 | #include "FreeRTOS.h"
18 | #include "projdefs.h"
19 | #include "semphr.h"
20 | #include "alt_types.h"
21 |
22 | #ifdef __cplusplus
23 | extern "C"
24 | {
25 | #endif /* __cplusplus */
26 |
27 | /*
28 | * alt_sem_create() is a wrapper for xSemaphoreCreateCounting(). The return value is 0 if
29 | * the semaphore has been successfully created, or non-zero otherwise.
30 | */
31 | static ALT_INLINE int ALT_ALWAYS_INLINE alt_sem_create (xSemaphoreHandle* sem, alt_u16 value)
32 | {
33 | *sem = xSemaphoreCreateCounting(value ? value : 1, value);
34 | return *sem ? 0 : -1;
35 | }
36 |
37 | /*
38 | * alt_sem_pend() is a wrapper for xSemaphoreTake(), with the error code
39 | * converted into the functions return value.
40 | */
41 |
42 | static ALT_INLINE int ALT_ALWAYS_INLINE alt_sem_pend (xSemaphoreHandle sem, alt_u16 timeout)
43 | {
44 | return xSemaphoreTake(sem, timeout) ? 0 : -1;
45 | }
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* __ALT_SEM_FREERTOS_H__ */
52 |
--------------------------------------------------------------------------------
/altera_nios2/altera_nios2_freertos_sw.tcl:
--------------------------------------------------------------------------------
1 | #
2 | # altera_nios2_driver_freertos.tcl
3 | #
4 |
5 | # Create a new driver
6 | create_driver altera_nios2_freertos_driver
7 |
8 | # Associate it with some hardware known as "altera_nios2"
9 | set_sw_property hw_class_name altera_nios2
10 |
11 | # The version of this driver
12 | set_sw_property version 12.0
13 |
14 | # This driver may be incompatible with versions of hardware less
15 | # than specified below. Updates to hardware and device drivers
16 | # rendering the driver incompatible with older versions of
17 | # hardware are noted with this property assignment.
18 | set_sw_property min_compatible_hw_version 8.0
19 |
20 | # Initialize the driver in alt_irq_init() if this module
21 | # is recognized as containing an interrupt controller.
22 | set_sw_property irq_auto_initialize true
23 |
24 | # Location in generated BSP that above sources will be copied into
25 | set_sw_property bsp_subdirectory HAL
26 |
27 |
28 | # This driver supports the FreeRTOS BSP (OS) type
29 | add_sw_property supported_bsp_type FreeRTOS
30 |
31 | # This uses the $argv0 pre-set variable which contains the
32 | # complete path to this script.
33 | set dir [file dirname $argv0]
34 |
35 | #
36 | # Source file listings...
37 | #
38 |
39 | # C/C++ source files
40 | add_sw_property c_source HAL/src/altera_nios2_irq.c
41 |
42 | # Include files
43 | add_sw_property include_source HAL/inc/altera_nios2_irq.h
44 |
45 | # HAL driver common settings
46 | source $dir/altera_nios2_hal_common.tcl
47 |
48 | # uC/OS-II driver common settings
49 | source $dir/altera_nios2_freertos_common.tcl
50 |
51 | # End of file
52 |
--------------------------------------------------------------------------------
/altera_nios2/altera_nios2_qsys_freertos_sw.tcl:
--------------------------------------------------------------------------------
1 | #
2 | # altera_nios2_qsys_driver_freertos.tcl
3 | #
4 |
5 | # Create a new driver
6 | create_driver altera_nios2_qsys_freertos_driver
7 |
8 | # Associate it with some hardware known as "altera_nios2_qsys"
9 | set_sw_property hw_class_name altera_nios2_qsys
10 |
11 | # The version of this driver
12 | set_sw_property version 12.0
13 |
14 | # This driver may be incompatible with versions of hardware less
15 | # than specified below. Updates to hardware and device drivers
16 | # rendering the driver incompatible with older versions of
17 | # hardware are noted with this property assignment.
18 | set_sw_property min_compatible_hw_version 8.0
19 |
20 | # Initialize the driver in alt_irq_init() if this module
21 | # is recognized as containing an interrupt controller.
22 | set_sw_property irq_auto_initialize true
23 |
24 | # Location in generated BSP that above sources will be copied into
25 | set_sw_property bsp_subdirectory HAL
26 |
27 |
28 | # This driver supports the FreeRTOS BSP (OS) type
29 | add_sw_property supported_bsp_type FreeRTOS
30 |
31 | # This uses the $argv0 pre-set variable which contains the
32 | # complete path to this script.
33 | set dir [file dirname $argv0]
34 |
35 | #
36 | # Source file listings...
37 | #
38 |
39 | # C/C++ source files
40 | add_sw_property c_source HAL/src/altera_nios2_qsys_irq.c
41 |
42 | # Include files
43 | add_sw_property include_source HAL/inc/altera_nios2_qsys_irq.h
44 |
45 | # HAL driver common settings
46 | source $dir/altera_nios2_hal_common.tcl
47 |
48 | # uC/OS-II driver common settings
49 | source $dir/altera_nios2_freertos_common.tcl
50 |
51 | # End of file
52 |
--------------------------------------------------------------------------------
/freertos_demo/template.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/src/core/ipv4/inet.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Functions common to all TCP/IPv4 modules, such as the byte order functions.
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/inet.h"
42 |
43 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 __PERF_H__
33 | #define __PERF_H__
34 |
35 | #define PERF_START /* null definition */
36 | #define PERF_STOP(x) /* null definition */
37 |
38 | #endif /* __PERF_H__ */
39 |
--------------------------------------------------------------------------------
/freertos_demo/echo_server.c:
--------------------------------------------------------------------------------
1 | // include LwIP headers
2 | #include
3 | #include
4 |
5 | // include FreeRTOS headers
6 | #include
7 | #include
8 | #include
9 |
10 | #if LWIP_SOCKET == 1
11 | void prvMySocketTest(__unused void *params)
12 | {
13 | // create server socket stuff
14 | int lSocket;
15 | struct sockaddr_in sLocalAddr;
16 |
17 | printf("Starting socket test interface.\n");
18 |
19 | lSocket = socket(AF_INET, SOCK_STREAM, 0);
20 | printf("socket returns %d\n", lSocket);
21 | if (lSocket < 0) {
22 | perror("socket");
23 | return;
24 | }
25 |
26 | memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));
27 | sLocalAddr.sin_family = AF_INET;
28 | sLocalAddr.sin_len = sizeof(sLocalAddr);
29 | sLocalAddr.sin_addr.s_addr = 0;
30 | sLocalAddr.sin_port = htons(23);
31 |
32 | printf("Binding socket\n");
33 | if (bind(lSocket, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr)) < 0) {
34 | perror("bind");
35 | close(lSocket);
36 | return;
37 | }
38 |
39 | printf("Listening for socket\n");
40 | if (listen(lSocket, 20) != 0) {
41 | perror("listen");
42 | close(lSocket);
43 | return;
44 | }
45 |
46 | while (1) {
47 | int clientfd;
48 | struct sockaddr_in client_addr;
49 | int addrlen = sizeof(client_addr);
50 | char buffer[1024];
51 | int nbytes;
52 |
53 | printf("Waiting for new client\n");
54 |
55 | clientfd = accept(lSocket, (struct sockaddr*)&client_addr, (socklen_t*)&addrlen);
56 | printf("client socket %d connected from %s\n", clientfd, print_ipad(client_addr.sin_addr.s_addr));
57 | if (clientfd > 0) {
58 | do {
59 | nbytes = read(clientfd, buffer, sizeof(buffer));
60 | if (nbytes > 0)
61 | write(clientfd, buffer, nbytes);
62 |
63 | } while (nbytes>0);
64 |
65 | if (!close(clientfd))
66 | perror("close client");
67 | }
68 | else
69 | perror("accept");
70 | }
71 |
72 | if (!close(lSocket))
73 | perror("close server");
74 | }
75 | #endif
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/altera_tse_ethernetif.h:
--------------------------------------------------------------------------------
1 | #ifndef ALTERATSEETHERNETIF_H_
2 | #define ALTERATSEETHERNETIF_H_
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | #include
11 |
12 | // This times PBUF_POOL_BUFSIZE+4 is the amount of memory used to buffer incoming packets.
13 | // This can be small if you dedicate sufficient time to process incoming packets.
14 | // If it's too small, lwIP will run - only incoming packets will be dropped.
15 | #define LWIP_RX_ETH_BUFFER 12
16 | #define LWIP_RECEIVE_SEMAPHORE 1
17 |
18 | struct ethernetif;
19 | int tse_mac_init(int iface, struct ethernetif *ethernetif);
20 |
21 | /**
22 | * Private data used to operate your ethernet interface.
23 | */
24 | struct ethernetif {
25 | struct eth_addr *ethaddr;
26 | volatile int iface;
27 | volatile int link_alive;
28 | volatile int link_speed;
29 | volatile int full_duplex;
30 |
31 | // Extra stats
32 | volatile unsigned bytes_sent;
33 | volatile unsigned bytes_recv;
34 |
35 | // lwIP pbuf circular buffer. A list of pbufs that are used to store
36 | // incoming Ethernet packets
37 | struct pbuf *lwipRxPbuf[LWIP_RX_ETH_BUFFER];
38 | volatile int lwipRxIndexIsr;
39 | volatile int lwipRxIndex;
40 | volatile int lwipRxCount;
41 |
42 | volatile int current_state;
43 |
44 | // Pointer to TSE hardware descriptor - needed to send packets
45 | struct _lwip_tse_info *tse_info;
46 | };
47 |
48 | /* Base-Structure for all lwIP TSE information */
49 | typedef struct _lwip_tse_info
50 | {
51 | tse_mac_trans_info mi; /* MAC base driver data. */
52 |
53 | // Location for the SGDMA Descriptors
54 | alt_sgdma_descriptor *desc;
55 |
56 | // lwIP Ethernetif structure
57 | struct ethernetif *ethernetif;
58 |
59 | // Hardware location
60 | alt_tse_system_info *tse;
61 |
62 | #if LWIP_RECEIVE_SEMAPHORE
63 | sys_sem_t rx_semaphore;
64 | #endif
65 | } lwip_tse_info;
66 |
67 | extern lwip_tse_info tse[PHY_COUNT];
68 |
69 | err_t ethernetif_init(struct netif *netif);
70 | int ethernetif_input(struct netif *netif);
71 |
72 | #endif /*ALTERATSEETHERNETIF_H_*/
73 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/ping.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file ping.h
3 | *
4 | * This file provides easy access to a ping interface.
5 | *
6 | * Created on: 6 jan. 2012
7 | *
8 | * Created by: Engineering Spirit (c) 2012 http://engineering-spirit.nl/
9 | */
10 |
11 | #ifndef __LWIP_PING_H_
12 | #define __LWIP_PING_H_
13 |
14 | #ifdef __cplusplus
15 | extern "C"
16 | {
17 | #endif
18 |
19 | // include typedefs and such
20 | #include
21 |
22 | /**
23 | * \brief This functions sends a default ICMP ping.
24 | *
25 | * This function sends the number of ICMP ping requests you specifie. It can wait for a pong if you like.
26 | * The return value is counter started from 0 for each successfull packed send. If you set get_response to
27 | * one the counter will be increased with 1 if it receives a pong replay and decresed with 1 if the pong
28 | * request times out.
29 | *
30 | * \param [in] addr the address in network byte order to ping
31 | * \param [in] packets number of packets to be send
32 | * \param [in] get_response set to one if you want to wait for a response
33 | * \param [in] size the size of the packet to be send (the data send will be byte buffer with sequential count)
34 | *
35 | * \return the counter value
36 | */
37 | int lwip_ping_target(u32_t addr, u8_t packets, int get_response, u8_t size);
38 |
39 | /**
40 | * \brief This functions sends a default ICMP ping.
41 | *
42 | * This function sends the number of ICMP ping requests you specifie. It can wait for a pong if you like.
43 | * The return value is counter started from 0 for each successfull packed send. If you set get_response to
44 | * one the counter will be increased with 1 if it receives a pong replay and decresed with 1 if the pong
45 | * request times out.
46 | *
47 | * \param [in] addr the address in network byte order to ping
48 | * \param [in] packets number of packets to be send
49 | * \param [in] get_response set to one if you want to wait for a response
50 | * \param [in] data the data which would be the body of the ICMP ping request
51 | * \param [in] length the length of the given data
52 | *
53 | * \return the counter value
54 | */
55 | int lwip_ping_target_data(u32_t addr, u8_t packets, int get_response, u8_t *data, u16_t length);
56 |
57 | #ifdef __cplusplus
58 | }
59 | #endif
60 |
61 | #endif /* __LWIP_PING_H_ */
62 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/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 |
--------------------------------------------------------------------------------
/freertos_demo/BasicWEB.h:
--------------------------------------------------------------------------------
1 | /*This file has been prepared for Doxygen automatic documentation generation.*/
2 | /*! \file *********************************************************************
3 | *
4 | * \brief Basic WEB Server for AVR32 UC3.
5 | *
6 | * - Compiler: GNU GCC for AVR32
7 | * - Supported devices: All AVR32 devices can be used.
8 | * - AppNote:
9 | *
10 | * \author Atmel Corporation: http://www.atmel.com \n
11 | * Support and FAQ: http://support.atmel.no/
12 | *
13 | *****************************************************************************/
14 |
15 | /* Copyright (c) 2007, Atmel Corporation All rights reserved.
16 | *
17 | * Redistribution and use in source and binary forms, with or without
18 | * modification, are permitted provided that the following conditions are met:
19 | *
20 | * 1. Redistributions of source code must retain the above copyright notice,
21 | * this list of conditions and the following disclaimer.
22 | *
23 | * 2. Redistributions in binary form must reproduce the above copyright notice,
24 | * this list of conditions and the following disclaimer in the documentation
25 | * and/or other materials provided with the distribution.
26 | *
27 | * 3. The name of ATMEL may not be used to endorse or promote products derived
28 | * from this software without specific prior written permission.
29 | *
30 | * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
33 | * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
34 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
39 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 | */
41 |
42 |
43 | #ifndef BASIC_WEB_SERVER_H
44 | #define BASIC_WEB_SERVER_H
45 |
46 | #include "portmacro.h"
47 |
48 |
49 | /*! \brief WEB server main task
50 | *
51 | * \param pvParameters Input. Not Used.
52 | *
53 | */
54 | portTASK_FUNCTION_PROTO( vBasicWEBServer, pvParameters );
55 |
56 | #endif
57 |
58 |
--------------------------------------------------------------------------------
/altera_nios2/FreeRTOS/src/component.mk:
--------------------------------------------------------------------------------
1 | # *******************************************************************************
2 | # * *
3 | # * License Agreement *
4 | # * *
5 | # * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
6 | # * All rights reserved. *
7 | # * *
8 | # * Permission is hereby granted, free of charge, to any person obtaining a *
9 | # * copy of this software and associated documentation files (the "Software"), *
10 | # * to deal in the Software without restriction, including without limitation *
11 | # * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | # * and/or sell copies of the Software, and to permit persons to whom the *
13 | # * Software is furnished to do so, subject to the following conditions: *
14 | # * *
15 | # * The above copyright notice and this permission notice shall be included in *
16 | # * all copies or substantial portions of the Software. *
17 | # * *
18 | # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | # * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | # * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | # * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | # * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | # * DEALINGS IN THE SOFTWARE. *
25 | # * *
26 | # * This agreement shall be governed in all respects by the laws of the State *
27 | # * of California and by the laws of the United States of America. *
28 | # * *
29 | # * Altera does not recommend, suggest or require that this reference design *
30 | # * file be used in conjunction or combination with any other product. *
31 | # *******************************************************************************
32 |
33 | # List all source files supplied by this component.
34 |
35 | C_LIB_SRCS += alt_usleep.c
36 | C_LIB_SRCS += altera_avalon_tse.h
37 |
38 | ASM_LIB_SRCS +=
39 |
40 | INCLUDE_PATH +=
41 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Nios updated port for NiosEDS 11.0 and up
2 | Engineering Spirit (c) 2012 - 2013
3 |
4 | We updated the Nios II FreeRTOS port with the following changes:
5 | Fixed bug report:
6 | - Nios II port bug when using -O3 or -Os - ID: 3037968
7 | Changed:
8 | - It's now possible to keep interrupts enabled while the scheduler has not been started yet. (So now it's possible to print output via USART before the OS is started for example...)
9 | - The FreeRTOS tick handler is called via the timer hook provided by the Nios II HAL library.
10 |
11 | To use FreeRTOS as BSP the following hardware is required:
12 | (jtag_)uart or something ( this is where print message will end up)
13 | an sys_clk_timer (I'm running at 1ms, but any speed would be sufficient)
14 |
15 | To run the provided demo (Only one included which uses FreeRTOS and LwIP) you would need to have an Triple Speed Ethernet addapter included in your Nios II blok.
16 |
17 | !!! Note !!! - currently using a modified version of the LwIP-1.4.1 TCP/IP stack
18 | - The LwIP stack uses a modifed version of the socket API, which gives the sockets an offset, so we can let the HAL layer determent wether the read/write/flush calls should invoke the Altera HAL library or LwIP
19 | - We also applied a patch for proper packet routing if multiple interfaces are in the same subnet. For incomming and outgoing, also when UDP broadcasts are received when both interfaces are on the same subnet, this is routed to both the packet handling of both interfaces instead of just the first.
20 |
21 | Installation instructions:
22 | If you are on a unix system and have wget and curl installed, skip step 1 and 2.
23 |
24 | 1. Download the latest FreeRTOS kernel from www.freertos.org (currently v7.3.0)
25 | 2. Unzip the latest FreeRTOS source into FreeRTOS_src directory.
26 | 3. Execute alt-freertos-lwip-install.bat if your on windows or alt-freertos-lwip-install.sh if your on a unix like system.
27 | 4. Follow the steps provided by the console.
28 |
29 | Howto test your FreeRTOS OS installation
30 |
31 | In the Nios Software Build tools for eclipse, choose File ->New -> Nios II Board Support Package
32 | In the dialogue box that appears you should be able to select "Real Time Engineers Ltd FreeRTOS 7.3.0" if you choose a .sopcinfo file you should be able to build a BSP.
33 | To test your application
34 |
35 | In the Nios Software Build tools for eclipse, choose File ->New -> Nios II Application and BSP from Template
36 | Here you should be able to select "FreeRTOS - LwIP Demo" and build a system.
37 |
38 | Changes for multiple PHY support:
39 | Naming convension for network interfaces changed, now peripherals must be matched in this way (the 0 can be replaced by any value from 0 till 9):
40 | - tse_mac_0
41 | - sgdma_tse_rx_0
42 | - sgdma_tse_tx_0
43 | - tse_descriptor_memory_0
44 |
45 | Clearly if you want to change the code you can remove most of these restrictions. But these are the requirements for the "out of box" experience.
46 |
47 | Further more are there some changes in the application to BSP interface for ethernet handling. Please read 'lwip\FreeRTOS\inc\lwip_main.h' for more info.
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/freertos/freertos_systemh_generation.tcl:
--------------------------------------------------------------------------------
1 | #
2 | # freertos_systemh_generation.tcl
3 | #
4 | proc create_os_ticks_per_sec_macro {} {
5 | # Get BSP system timer name
6 | set timer_name [get_setting hal.sys_clk_timer]
7 |
8 | # Convert to upper-case
9 | set timer_name [string toupper $timer_name]
10 |
11 | #
12 | # Bail if not assigned
13 | #
14 | # If timer is assigned, add system.h macro. Should look like:
15 | # "#define OS_TICKS_PER_SEC _TICKS_PER_SEC
16 | if {[string compare $timer_name "NONE"] == 0} {
17 | puts "ERROR: FreeRTOS system.h generation tcl script:"
18 | puts " --> HAL system timer not defined. FreeRTOS may not build!"
19 | puts " --> Set hal.sys_clk_timer to a timer device and then re-generate the BSP."
20 | } else {
21 | set tps_str _TICKS_PER_SEC
22 | set tps_setting $timer_name$tps_str
23 |
24 | # Add to system.h content for FreeRTOS OS
25 | add_systemh_line FreeRTOS OS_TICKS_PER_SEC $tps_setting
26 | }
27 | }
28 |
29 | proc resolve_ethernet_macs {} {
30 | set phy_count 0
31 |
32 | foreach slave [get_slave_descs] {
33 | set module [get_module_name $slave]
34 |
35 | #if [is_ethernet_mac_device $slave] {
36 | if {[scan $slave "tse_mac_%d" nr] != 1} {
37 | continue
38 | }
39 |
40 | # see if we can find an SGDMA_TSE_TX_# and SGDMA_TSE_RX_# and TSE_DESCRIPTOR_MEMORY_#
41 | set found_tx 0
42 | set found_rx 0
43 | set found_descriptor 0
44 |
45 | set rx_challenge [format "sgdma_tse_rx_%d" $nr]
46 | set tx_challenge [format "sgdma_tse_tx_%d" $nr]
47 | set descriptor_challenge [format "tse_descriptor_memory_%d" $nr]
48 |
49 | foreach tmp [get_slave_descs] {
50 | if {[string compare $tmp $rx_challenge] == 0} {
51 | set found_rx 1
52 | } elseif {[string compare $tmp $tx_challenge] == 0} {
53 | set found_tx 1
54 | } elseif {[string compare $tmp $descriptor_challenge] == 0} {
55 | set found_descriptor 1
56 | }
57 | }
58 |
59 | if {$found_tx == 0} {
60 | puts "ERROR: Couldn't find a matching transmit SGDMA controller for $slave"
61 | }
62 |
63 | if {$found_rx == 0} {
64 | puts "ERROR: Couldn't find a matching receive SGDMA controller for $slave"
65 | }
66 |
67 | if {$found_descriptor == 0} {
68 | puts "ERROR: Couldn't find matching descriptor memory for $slave"
69 | }
70 |
71 | if {$found_tx == 0 || $found_rx == 0 || $found_descriptor == 0} {
72 | continue;
73 | }
74 |
75 | puts "INFO: Adding ethernet MAC $slave to the TSE driver"
76 |
77 | add_systemh_line FreeRTOS [format "GOT_TSE_MAC_%d" $nr] 1
78 |
79 | set phy_count [expr $phy_count + 1]
80 | #} else {
81 | # set bla [is_ethernet_mac_device $slave]
82 | # puts "ERROR: Not an TSE MAC: $slave - $bla"
83 | #}
84 | }
85 |
86 | # we have tell the system
87 | if { $phy_count != 0 } {
88 | add_systemh_line FreeRTOS TSE_MY_SYSTEM 1
89 | }
90 |
91 | add_systemh_line FreeRTOS PHY_COUNT $phy_count
92 | }
93 |
94 | # Call procedure to generate OS_TICKS_PER_SEC macro
95 | create_os_ticks_per_sec_macro
96 | resolve_ethernet_macs
97 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 | struct pbuf_custom_ref {
74 | /** 'base class' */
75 | struct pbuf_custom pc;
76 | /** pointer to the original pbuf that is referenced */
77 | struct pbuf *original;
78 | };
79 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
80 |
81 | err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest);
82 | #endif /* IP_FRAG */
83 |
84 | #ifdef __cplusplus
85 | }
86 | #endif
87 |
88 | #endif /* __LWIP_IP_FRAG_H__ */
89 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/freertos/FreeRTOS/src/alt_env_lock.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | ******************************************************************************/
30 |
31 | // Provided by Engineering Spirit (c) 2012
32 |
33 | #include "system.h"
34 |
35 | /*
36 | * These are the malloc lock/unlock stubs required by newlib. These are
37 | * used to make accesses to the heap thread safe. Note that
38 | * this implementation requires that the heap is never manipulated
39 | * by an interrupt service routine.
40 | */
41 |
42 | #include
43 |
44 | #include "FreeRTOS.h"
45 | #include "projdefs.h"
46 | #include "semphr.h"
47 | #include "task.h"
48 |
49 | /* semaphore to protect the heap */
50 |
51 | xSemaphoreHandle alt_envsem;
52 |
53 | /* __env_lock needs to provide recursive mutex locking */
54 |
55 | void __env_lock ( struct _reent *_r )
56 | {
57 | #if OS_THREAD_SAFE_NEWLIB
58 | if (!xTaskGetSchedulerState())
59 | return;
60 |
61 | // wait for the mutex to be released
62 | while (xSemaphoreTakeRecursive(alt_envsem, 10) != pdTRUE)
63 | vTaskDelay(1);
64 |
65 | #endif /* OS_THREAD_SAFE_NEWLIB */
66 | return;
67 | }
68 |
69 | /* __env_unlock needs to provide recursive mutex unlocking */
70 |
71 | void __env_unlock ( struct _reent *_r )
72 | {
73 | #if OS_THREAD_SAFE_NEWLIB
74 | if (!xTaskGetSchedulerState())
75 | return;
76 |
77 | xSemaphoreGiveRecursive(alt_envsem);
78 | #endif /* OS_THREAD_SAFE_NEWLIB */
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/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 |
--------------------------------------------------------------------------------
/freertos/FreeRTOS/src/alt_malloc_lock.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | ******************************************************************************/
30 |
31 | // Provided by Engineering Spirit (c) 2012
32 |
33 | #include "system.h"
34 |
35 | /*
36 | * These are the malloc lock/unlock stubs required by newlib. These are
37 | * used to make accesses to the heap thread safe. Note that
38 | * this implementation requires that the heap is never manipulated
39 | * by an interrupt service routine.
40 | */
41 |
42 | #include
43 |
44 | #include "FreeRTOS.h"
45 | #include "projdefs.h"
46 | #include "semphr.h"
47 | #include "task.h"
48 |
49 | /* semaphore to protect the heap */
50 |
51 | xSemaphoreHandle alt_heapsem;
52 |
53 | /* __malloc_lock needs to provide recursive mutex locking */
54 |
55 | void __malloc_lock ( struct _reent *_r )
56 | {
57 | #if OS_THREAD_SAFE_NEWLIB
58 | if (!xTaskGetSchedulerState())
59 | return;
60 |
61 | // wait for the mutex to be released
62 | while (xSemaphoreTakeRecursive(alt_heapsem, 10) != pdTRUE)
63 | vTaskDelay(1);
64 |
65 | #endif /* OS_THREAD_SAFE_NEWLIB */
66 | return;
67 | }
68 |
69 | /* __malloc_unlock needs to provide recursive mutex unlocking */
70 |
71 | void __malloc_unlock ( struct _reent *_r )
72 | {
73 | #if OS_THREAD_SAFE_NEWLIB
74 | if (!xTaskGetSchedulerState())
75 | return;
76 |
77 | xSemaphoreGiveRecursive(alt_heapsem);
78 | #endif /* OS_THREAD_SAFE_NEWLIB */
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/ipv4/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,
76 | ip_addr_t *src, ip_addr_t *dest,
77 | u8_t proto, u16_t proto_len);
78 | u16_t inet_chksum_pseudo_partial(struct pbuf *p,
79 | ip_addr_t *src, ip_addr_t *dest,
80 | u8_t proto, u16_t proto_len, u16_t chksum_len);
81 | #if LWIP_CHKSUM_COPY_ALGORITHM
82 | u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len);
83 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */
84 |
85 | #ifdef __cplusplus
86 | }
87 | #endif
88 |
89 | #endif /* __LWIP_INET_H__ */
90 |
91 |
--------------------------------------------------------------------------------
/altera_nios2/FreeRTOS/src/alt_usleep.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Altera Corporation, San Jose, California, USA.
3 | * All rights reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to
7 | * deal in the Software without restriction, including without limitation the
8 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 | * sell copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 | * DEALINGS IN THE SOFTWARE.
22 | *
23 | * ------------
24 | *
25 | * Altera does not recommend, suggest or require that this reference design
26 | * file be used in conjunction or combination with any other product.
27 | */
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | #include "sys/alt_alarm.h"
34 | #include "priv/alt_busy_sleep.h"
35 | #include "os/alt_syscall.h"
36 |
37 | #include "FreeRTOS.h"
38 | #include "task.h"
39 |
40 | /*
41 | * Macro defining the number of micoseconds in a second.
42 | */
43 |
44 | #define ALT_US (1000000)
45 |
46 | extern int prvRunning;
47 |
48 | /*
49 | * This implementation of usleep overrides the default provided in the HAL/src
50 | * directory of the altera_nios2 component. When possible, this
51 | * implementation uses the uC/OS-II OSTimeDly function to block the current
52 | * thread, rather than using a busy loop. This allows other threads to execute
53 | * while the current thread is sleeping.
54 | *
55 | * ALT_USLEEP is mapped onto the usleep() system call in alt_syscall.h
56 | */
57 |
58 | #if defined (__GNUC__) && __GNUC__ >= 4
59 | int ALT_USLEEP (useconds_t us)
60 | #else
61 | unsigned int ALT_USLEEP (unsigned int us)
62 | #endif
63 | {
64 | alt_u32 ticks;
65 | alt_u32 tick_rate;
66 |
67 | /*
68 | * If the O/S hasn't started yet, then we delay using a busy loop, rather than
69 | * vTaskDelay (since this would fail). The use of a busy loop is acceptable,
70 | * since the system is still running in a single-threaded mode.
71 | */
72 |
73 | if (!xTaskGetSchedulerState())
74 | {
75 | return alt_busy_sleep (us);
76 | }
77 |
78 | /*
79 | * Calculate the number of whole system clock ticks to delay.
80 | */
81 |
82 | tick_rate = alt_ticks_per_second ();
83 | ticks = (us/ALT_US)* tick_rate + ((us%ALT_US)*tick_rate)/ALT_US;
84 |
85 | /*
86 | * vTaskDelay can only delay for a maximum of 0xffff ticks, so if the requested
87 | * delay is greater than that, we need to break it down into a number of
88 | * seperate delays.
89 | */
90 |
91 | while (ticks > 0xffff)
92 | {
93 | vTaskDelay(0xffff);
94 | ticks -= 0xffff;
95 | }
96 |
97 | vTaskDelay ((alt_u16) (ticks));
98 |
99 | /*
100 | * Now delay by the remainder using a busy loop. This is here in order to
101 | * provide very short delays of less than one clock tick.
102 | */
103 |
104 | alt_busy_sleep (us%(ALT_US/tick_rate));
105 |
106 | return 0;
107 | }
108 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/lwip/raw.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_RAW_H__
33 | #define __LWIP_RAW_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
38 |
39 | #include "lwip/pbuf.h"
40 | #include "lwip/def.h"
41 | #include "lwip/ip.h"
42 | #include "lwip/ip_addr.h"
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | struct raw_pcb;
49 |
50 | /** Function prototype for raw pcb receive callback functions.
51 | * @param arg user supplied argument (raw_pcb.recv_arg)
52 | * @param pcb the raw_pcb which received data
53 | * @param p the packet buffer that was received
54 | * @param addr the remote IP address from which the packet was received
55 | * @return 1 if the packet was 'eaten' (aka. deleted),
56 | * 0 if the packet lives on
57 | * If returning 1, the callback is responsible for freeing the pbuf
58 | * if it's not used any more.
59 | */
60 | typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
61 | ip_addr_t *addr);
62 |
63 | struct raw_pcb {
64 | /* Common members of all PCB types */
65 | IP_PCB;
66 |
67 | struct raw_pcb *next;
68 |
69 | u8_t protocol;
70 |
71 | /** receive callback function */
72 | raw_recv_fn recv;
73 | /* user-supplied argument for the recv callback */
74 | void *recv_arg;
75 | };
76 |
77 | /* The following functions is the application layer interface to the
78 | RAW code. */
79 | struct raw_pcb * raw_new (u8_t proto);
80 | void raw_remove (struct raw_pcb *pcb);
81 | err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr);
82 | err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr);
83 |
84 | void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
85 | err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr);
86 | err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
87 |
88 | /* The following functions are the lower layer interface to RAW. */
89 | u8_t raw_input (struct pbuf *p, struct netif *inp);
90 | #define raw_init() /* Compatibility define, not init needed. */
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif /* LWIP_RAW */
97 |
98 | #endif /* __LWIP_RAW_H__ */
99 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/os/alt_syscall.h:
--------------------------------------------------------------------------------
1 | #ifndef __ALT_SYSCALL_H__
2 | #define __ALT_SYSCALL_H__
3 |
4 | /******************************************************************************
5 | * *
6 | * License Agreement *
7 | * *
8 | * Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
9 | * All rights reserved. *
10 | * *
11 | * Permission is hereby granted, free of charge, to any person obtaining a *
12 | * copy of this software and associated documentation files (the "Software"), *
13 | * to deal in the Software without restriction, including without limitation *
14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
15 | * and/or sell copies of the Software, and to permit persons to whom the *
16 | * Software is furnished to do so, subject to the following conditions: *
17 | * *
18 | * The above copyright notice and this permission notice shall be included in *
19 | * all copies or substantial portions of the Software. *
20 | * *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
27 | * DEALINGS IN THE SOFTWARE. *
28 | * *
29 | * This agreement shall be governed in all respects by the laws of the State *
30 | * of California and by the laws of the United States of America. *
31 | * *
32 | ******************************************************************************/
33 |
34 | /*
35 | * The macros defined in this file are used to provide the function names used
36 | * for the HAL 'UNIX style' interface, e.g. read(), write() etc.
37 | *
38 | * Operating systems which are ported to the HAL can provide their own
39 | * version of this file, which will be used in preference. This allows
40 | * the operating system to provide it's own implementation of the top level
41 | * system calls, while retaining the HAL functions under a different name,
42 | * for example, alt_read(), alt_write() etc.
43 | */
44 |
45 | #define ALT_LWIP_ALT_SYSCALL_H
46 |
47 | #define ALT_CLOSE alt_close
48 | #define ALT_ENVIRON environ
49 | #define ALT_EXECVE execve
50 | #define ALT_EXIT _exit
51 | #define ALT_FCNTL alt_fcntl
52 | #define ALT_FORK fork
53 | #define ALT_FSTAT fstat
54 | #define ALT_GETPID getpid
55 | #define ALT_GETTIMEOFDAY gettimeofday
56 | #define ALT_IOCTL ioctl
57 | #define ALT_ISATTY isatty
58 | #define ALT_KILL kill
59 | #define ALT_LINK link
60 | #define ALT_LSEEK lseek
61 | #define ALT_OPEN open
62 | #define ALT_READ alt_read
63 | #define ALT_RENAME _rename
64 | #define ALT_SBRK sbrk
65 | #define ALT_SETTIMEOFDAY settimeofday
66 | #define ALT_STAT stat
67 | #define ALT_UNLINK unlink
68 | #define ALT_USLEEP usleep
69 | #define ALT_WAIT wait
70 | #define ALT_WRITE alt_write
71 | #define ALT_TIMES times
72 |
73 | /*
74 | *
75 | */
76 |
77 | #endif /* __ALT_ALIAS_H__ */
78 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/src/arch/alt_lwip_fcntl.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | * Altera does not recommend, suggest or require that this reference design *
30 | * file be used in conjunction or combination with any other product. *
31 | ******************************************************************************/
32 |
33 | /******************************************************************************
34 | * *
35 | * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. *
36 | * *
37 | * Overriding HAL Functions *
38 | * *
39 | ******************************************************************************/
40 |
41 | #include
42 | #include
43 | #include "system.h"
44 | #include "sys/alt_sys_wrappers.h"
45 | #include
46 |
47 | /*
48 | * fcntl() is called by an application to release a file descriptor. This
49 | * implementation duplicates the code of the HAL alt_fcntl() function
50 | * (for files and device drivers) or calls the InterNiche bsd_ioctl for
51 | * sockets.
52 | */
53 |
54 | int fcntl (int file, int cmd, ...)
55 | {
56 | long flags;
57 | va_list argp;
58 |
59 | if (file < ALT_MAX_FD)
60 | {
61 | va_start(argp, cmd);
62 | flags = va_arg(argp, long);
63 | va_end(argp);
64 | return ALT_FCNTL(file, cmd, flags);
65 | }
66 | #if LWIP_SOCKET
67 | else
68 | {
69 | va_start(argp, cmd);
70 | flags = va_arg(argp, long);
71 | va_end(argp);
72 | return lwip_fcntl(file, cmd, flags);
73 | }
74 | #else
75 | else
76 | return -1;
77 | #endif
78 | }
79 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/src/arch/alt_lwip_close.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | * Altera does not recommend, suggest or require that this reference design *
30 | * file be used in conjunction or combination with any other product. *
31 | ******************************************************************************/
32 |
33 | /******************************************************************************
34 | * *
35 | * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. *
36 | * *
37 | * Overriding HAL Functions *
38 | * *
39 | * To provide your own implementation of a HAL function, include the file in *
40 | * your Nios II IDE application project. When building the executable, the *
41 | * Nios II IDE finds your function first, and uses it in place of the HAL *
42 | * version. *
43 | * *
44 | ******************************************************************************/
45 |
46 | #include "system.h"
47 | #include "sys/alt_sys_wrappers.h"
48 | #include "lwip/sockets.h"
49 |
50 | /*
51 | * close() is called by an application to release a file descriptor. This
52 | * implementation vectors requests to either the HAL alt_close() function
53 | * (for files and device drivers) or the InterNiche soclose() function for
54 | * sockets.
55 | */
56 |
57 | int close (int fd)
58 | {
59 | if (fd < ALT_MAX_FD)
60 | return ALT_CLOSE (fd);
61 | #if LWIP_SOCKET
62 | else
63 | return lwip_close((long) fd);
64 | #else
65 | else
66 | return -1;
67 | #endif
68 | }
69 |
--------------------------------------------------------------------------------
/freertos/FreeRTOS/src/tse_ethernet_phys.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | ******************************************************************************/
30 | #include "system.h"
31 |
32 | #ifdef TSE_MY_SYSTEM
33 |
34 | #include "altera_avalon_tse.h"
35 | #include "altera_avalon_tse_system_info.h"
36 |
37 |
38 | alt_tse_system_info tse_mac_device[MAXNETS] = {
39 | /************************************************************************************/
40 | #ifdef GOT_TSE_MAC_0
41 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_0, 0, SGDMA_TSE_TX_0, SGDMA_TSE_RX_0, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_0)
42 | #endif
43 | #ifdef GOT_TSE_MAC_1
44 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_1, 0, SGDMA_TSE_TX_1, SGDMA_TSE_RX_1, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_1)
45 | #endif
46 | #ifdef GOT_TSE_MAC_2
47 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_2, 0, SGDMA_TSE_TX_2, SGDMA_TSE_RX_2, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_2)
48 | #endif
49 | #ifdef GOT_TSE_MAC_3
50 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_3, 0, SGDMA_TSE_TX_3, SGDMA_TSE_RX_3, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_3)
51 | #endif
52 | #ifdef GOT_TSE_MAC_4
53 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_4, 0, SGDMA_TSE_TX_4, SGDMA_TSE_RX_4, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_4)
54 | #endif
55 | #ifdef GOT_TSE_MAC_5
56 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_5, 0, SGDMA_TSE_TX_5, SGDMA_TSE_RX_5, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_5)
57 | #endif
58 | #ifdef GOT_TSE_MAC_6
59 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_6, 0, SGDMA_TSE_TX_6, SGDMA_TSE_RX_6, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_6)
60 | #endif
61 | #ifdef GOT_TSE_MAC_7
62 | TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(TSE_MAC_7, 0, SGDMA_TSE_TX_7, SGDMA_TSE_RX_7, TSE_PHY_AUTO_ADDRESS, 0, TSE_DESCRIPTOR_MEMORY_7)
63 | #endif
64 | /************************************************************************************/
65 | };
66 |
67 | #endif /* TSE_MY_SYSTEM */
68 |
69 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/src/arch/alt_lwip_write.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | * Altera does not recommend, suggest or require that this reference design *
30 | * file be used in conjunction or combination with any other product. *
31 | ******************************************************************************/
32 |
33 | /******************************************************************************
34 | * *
35 | * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. *
36 | * *
37 | * Overriding HAL Functions *
38 | * *
39 | * To provide your own implementation of a HAL function, include the file in *
40 | * your Nios II IDE application project. When building the executable, the *
41 | * Nios II IDE finds your function first, and uses it in place of the HAL *
42 | * version. *
43 | * *
44 | ******************************************************************************/
45 |
46 | #include
47 | #include "sys/alt_sys_wrappers.h"
48 | #include "system.h"
49 | #include
50 |
51 | /*
52 | * The write() system call is used to write a block of data to a file or device.
53 | * This implementation vectors requests to either the HAL alt_write() function
54 | * (for files and device drivers) or the InterNiche send() function for sockets.
55 | */
56 |
57 | int write (int fd, const void *ptr, size_t len)
58 | {
59 | if (fd < ALT_MAX_FD)
60 | return ALT_WRITE(fd, ptr, len);
61 | #if LWIP_SOCKET
62 | else
63 | return send (fd, (void*) ptr, len, 0);
64 | #else
65 | else
66 | return -1;
67 | #endif
68 | }
69 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/src/arch/alt_lwip_read.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * *
3 | * License Agreement *
4 | * *
5 | * Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
6 | * All rights reserved. *
7 | * *
8 | * Permission is hereby granted, free of charge, to any person obtaining a *
9 | * copy of this software and associated documentation files (the "Software"), *
10 | * to deal in the Software without restriction, including without limitation *
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | * and/or sell copies of the Software, and to permit persons to whom the *
13 | * Software is furnished to do so, subject to the following conditions: *
14 | * *
15 | * The above copyright notice and this permission notice shall be included in *
16 | * all copies or substantial portions of the Software. *
17 | * *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | * DEALINGS IN THE SOFTWARE. *
25 | * *
26 | * This agreement shall be governed in all respects by the laws of the State *
27 | * of California and by the laws of the United States of America. *
28 | * *
29 | * Altera does not recommend, suggest or require that this reference design *
30 | * file be used in conjunction or combination with any other product. *
31 | ******************************************************************************/
32 |
33 | /******************************************************************************
34 | * *
35 | * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. *
36 | * *
37 | * Overriding HAL Functions *
38 | * *
39 | * To provide your own implementation of a HAL function, include the file in *
40 | * your Nios II IDE application project. When building the executable, the *
41 | * Nios II IDE finds your function first, and uses it in place of the HAL *
42 | * version. *
43 | * *
44 | ******************************************************************************/
45 |
46 | #include
47 | #include "sys/alt_sys_wrappers.h"
48 | #include "system.h"
49 | #include
50 |
51 | /*
52 | * The read() system call is used to read a block of data from a file or device.
53 | * This implementation vectors requests to either the HAL alt_read() function
54 | * (for files and device drivers) or the InterNiche recvfrom() function for
55 | * sockets.
56 | */
57 |
58 | int read (int fd, void *ptr, size_t len)
59 | {
60 | if (fd < ALT_MAX_FD)
61 | return ALT_READ (fd, ptr, len);
62 | #if LWIP_SOCKET
63 | else
64 | return recvfrom(fd, ptr, len, 0, NULL, NULL);
65 | #else
66 | else
67 | return -1;
68 | #endif
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | #define ICMP_ER 0 /* echo reply */
45 | #define ICMP_DUR 3 /* destination unreachable */
46 | #define ICMP_SQ 4 /* source quench */
47 | #define ICMP_RD 5 /* redirect */
48 | #define ICMP_ECHO 8 /* echo */
49 | #define ICMP_TE 11 /* time exceeded */
50 | #define ICMP_PP 12 /* parameter problem */
51 | #define ICMP_TS 13 /* timestamp */
52 | #define ICMP_TSR 14 /* timestamp reply */
53 | #define ICMP_IRQ 15 /* information request */
54 | #define ICMP_IR 16 /* information reply */
55 |
56 | enum icmp_dur_type {
57 | ICMP_DUR_NET = 0, /* net unreachable */
58 | ICMP_DUR_HOST = 1, /* host unreachable */
59 | ICMP_DUR_PROTO = 2, /* protocol unreachable */
60 | ICMP_DUR_PORT = 3, /* port unreachable */
61 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
62 | ICMP_DUR_SR = 5 /* source route failed */
63 | };
64 |
65 | enum icmp_te_type {
66 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */
67 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
68 | };
69 |
70 | #ifdef PACK_STRUCT_USE_INCLUDES
71 | # include "arch/bpstruct.h"
72 | #endif
73 | /** This is the standard ICMP header only that the u32_t data
74 | * is splitted to two u16_t like ICMP echo needs it.
75 | * This header is also used for other ICMP types that do not
76 | * use the data part.
77 | */
78 | PACK_STRUCT_BEGIN
79 | struct icmp_echo_hdr {
80 | PACK_STRUCT_FIELD(u8_t type);
81 | PACK_STRUCT_FIELD(u8_t code);
82 | PACK_STRUCT_FIELD(u16_t chksum);
83 | PACK_STRUCT_FIELD(u16_t id);
84 | PACK_STRUCT_FIELD(u16_t seqno);
85 | } PACK_STRUCT_STRUCT;
86 | PACK_STRUCT_END
87 | #ifdef PACK_STRUCT_USE_INCLUDES
88 | # include "arch/epstruct.h"
89 | #endif
90 |
91 | #define ICMPH_TYPE(hdr) ((hdr)->type)
92 | #define ICMPH_CODE(hdr) ((hdr)->code)
93 |
94 | /** Combines type and code to an u16_t */
95 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t))
96 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c))
97 |
98 |
99 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
100 |
101 | void icmp_input(struct pbuf *p, struct netif *inp);
102 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
103 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
104 |
105 | #endif /* LWIP_ICMP */
106 |
107 | #ifdef __cplusplus
108 | }
109 | #endif
110 |
111 | #endif /* __LWIP_ICMP_H__ */
112 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 | typedef void (*netifapi_void_fn)(struct netif *netif);
45 | typedef err_t (*netifapi_errt_fn)(struct netif *netif);
46 |
47 | struct netifapi_msg_msg {
48 | #if !LWIP_TCPIP_CORE_LOCKING
49 | sys_sem_t sem;
50 | #endif /* !LWIP_TCPIP_CORE_LOCKING */
51 | err_t err;
52 | struct netif *netif;
53 | union {
54 | struct {
55 | ip_addr_t *ipaddr;
56 | ip_addr_t *netmask;
57 | ip_addr_t *gw;
58 | void *state;
59 | netif_init_fn init;
60 | netif_input_fn input;
61 | } add;
62 | struct {
63 | netifapi_void_fn voidfunc;
64 | netifapi_errt_fn errtfunc;
65 | } common;
66 | } msg;
67 | };
68 |
69 | struct netifapi_msg {
70 | void (* function)(struct netifapi_msg_msg *msg);
71 | struct netifapi_msg_msg msg;
72 | };
73 |
74 |
75 | /* API for application */
76 | err_t netifapi_netif_add ( struct netif *netif,
77 | ip_addr_t *ipaddr,
78 | ip_addr_t *netmask,
79 | ip_addr_t *gw,
80 | void *state,
81 | netif_init_fn init,
82 | netif_input_fn input);
83 |
84 | err_t netifapi_netif_set_addr ( struct netif *netif,
85 | ip_addr_t *ipaddr,
86 | ip_addr_t *netmask,
87 | ip_addr_t *gw );
88 |
89 | err_t netifapi_netif_common ( struct netif *netif,
90 | netifapi_void_fn voidfunc,
91 | netifapi_errt_fn errtfunc);
92 |
93 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
94 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
95 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
96 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
97 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
98 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
99 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
100 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
101 |
102 | #ifdef __cplusplus
103 | }
104 | #endif
105 |
106 | #endif /* LWIP_NETIF_API */
107 |
108 | #endif /* __LWIP_NETIFAPI_H__ */
109 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | /** This netbuf has dest-addr/port set */
44 | #define NETBUF_FLAG_DESTADDR 0x01
45 | /** This netbuf includes a checksum */
46 | #define NETBUF_FLAG_CHKSUM 0x02
47 |
48 | struct netbuf {
49 | struct pbuf *p, *ptr;
50 | ip_addr_t addr;
51 | u16_t port;
52 | #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
53 | #if LWIP_CHECKSUM_ON_COPY
54 | u8_t flags;
55 | #endif /* LWIP_CHECKSUM_ON_COPY */
56 | u16_t toport_chksum;
57 | #if LWIP_NETBUF_RECVINFO
58 | ip_addr_t toaddr;
59 | #endif /* LWIP_NETBUF_RECVINFO */
60 | #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
61 | };
62 |
63 | /* Network buffer functions: */
64 | struct netbuf * netbuf_new (void);
65 | void netbuf_delete (struct netbuf *buf);
66 | void * netbuf_alloc (struct netbuf *buf, u16_t size);
67 | void netbuf_free (struct netbuf *buf);
68 | err_t netbuf_ref (struct netbuf *buf,
69 | const void *dataptr, u16_t size);
70 | void netbuf_chain (struct netbuf *head,
71 | struct netbuf *tail);
72 |
73 | err_t netbuf_data (struct netbuf *buf,
74 | void **dataptr, u16_t *len);
75 | s8_t netbuf_next (struct netbuf *buf);
76 | void netbuf_first (struct netbuf *buf);
77 |
78 |
79 | #define netbuf_copy_partial(buf, dataptr, len, offset) \
80 | pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
81 | #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
82 | #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
83 | #define netbuf_len(buf) ((buf)->p->tot_len)
84 | #define netbuf_fromaddr(buf) (&((buf)->addr))
85 | #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr)
86 | #define netbuf_fromport(buf) ((buf)->port)
87 | #if LWIP_NETBUF_RECVINFO
88 | #define netbuf_destaddr(buf) (&((buf)->toaddr))
89 | #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr)
90 | #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
91 | #endif /* LWIP_NETBUF_RECVINFO */
92 | #if LWIP_CHECKSUM_ON_COPY
93 | #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
94 | (buf)->toport_chksum = chksum; } while(0)
95 | #endif /* LWIP_CHECKSUM_ON_COPY */
96 |
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
101 | #endif /* __LWIP_NETBUF_H__ */
102 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/freertos/FreeRTOS/inc/os/alt_sem.h:
--------------------------------------------------------------------------------
1 | #ifndef __ALT_SEM_H__
2 | #define __ALT_SEM_H__
3 |
4 | /******************************************************************************
5 | * *
6 | * License Agreement *
7 | * *
8 | * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
9 | * All rights reserved. *
10 | * *
11 | * Permission is hereby granted, free of charge, to any person obtaining a *
12 | * copy of this software and associated documentation files (the "Software"), *
13 | * to deal in the Software without restriction, including without limitation *
14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
15 | * and/or sell copies of the Software, and to permit persons to whom the *
16 | * Software is furnished to do so, subject to the following conditions: *
17 | * *
18 | * The above copyright notice and this permission notice shall be included in *
19 | * all copies or substantial portions of the Software. *
20 | * *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
27 | * DEALINGS IN THE SOFTWARE. *
28 | * *
29 | * This agreement shall be governed in all respects by the laws of the State *
30 | * of California and by the laws of the United States of America. *
31 | * *
32 | ******************************************************************************/
33 |
34 | /*
35 | * This header provides macro definitions that can be used to create and use
36 | * semaphores. These macros can be used in both a FreeRTOS based environment,
37 | * and a single threaded HAL based environment.
38 | *
39 | * The motivation for these macros is to allow code to be developed which is
40 | * thread safe under FreeRTOS, but incurs no additional overhead when used in a
41 | * single threaded HAL environment.
42 | *
43 | * In the case of a single threaded HAL environment, they compile to
44 | * "do nothing" directives, which ensures they do not contribute to the final
45 | * executable. The macro definitions used in that case are supplied with the
46 | * HAL.
47 | *
48 | * The following macros are available:
49 | *
50 | * ALT_SEM - Create a semaphore instance.
51 | * ALT_EXTERN_SEM - Create a reference to an external semaphore instance.
52 | * ALT_STATIC_SEM - Create a static semaphore instance.
53 | * ALT_SEM_CREATE - Initialise a semaphore.
54 | * ALT_SEM_PEND - Pend on a semaphore.
55 | * ALT_SEM_POST - Increment a semaphore.
56 | *
57 | * Input arguments and return codes are all consistant with the equivalent
58 | * FreeRTOS function.
59 | *
60 | * It's important to be careful in the use of the macros: ALT_SEM,
61 | * ALT_EXTERN_SEM, and ALT_STATIC_SEM. In these three cases the semi-colon is
62 | * included in the macro definition; so, for example, you should use:
63 | *
64 | * ALT_SEM(mysem)
65 | *
66 | * not:
67 | *
68 | * ALT_SEM(mysem);
69 | *
70 | * The inclusion of the semi-colon has been necessary to ensure the macros can
71 | * compile with no warnings when used in a single threaded HAL environment.
72 | *
73 | */
74 |
75 | // Provided by Engineering Spirit (c) 2012
76 |
77 | #include "priv/alt_sem_freertos.h"
78 |
79 | #define ALT_SEM(sem) xSemaphoreHandle sem;
80 | #define ALT_EXTERN_SEM(sem) extern xSemaphoreHandle sem;
81 | #define ALT_STATIC_SEM(sem) static xSemaphoreHandle sem;
82 |
83 | #define ALT_SEM_CREATE(sem, value) alt_sem_create (sem, value)
84 | #define ALT_SEM_PEND(sem, timeout) alt_sem_pend (sem, timeout)
85 | #define ALT_SEM_POST(sem) xSemaphoreGive (sem)
86 |
87 | #endif /* __ALT_SEM_H__ */
88 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 | /** For compatibility with BSD code */
44 | struct in_addr {
45 | u32_t s_addr;
46 | };
47 |
48 | /** 255.255.255.255 */
49 | #define INADDR_NONE IPADDR_NONE
50 | /** 127.0.0.1 */
51 | #define INADDR_LOOPBACK IPADDR_LOOPBACK
52 | /** 0.0.0.0 */
53 | #define INADDR_ANY IPADDR_ANY
54 | /** 255.255.255.255 */
55 | #define INADDR_BROADCAST IPADDR_BROADCAST
56 |
57 | /* Definitions of the bits in an Internet address integer.
58 |
59 | On subnets, host and network parts are found according to
60 | the subnet mask, not these masks. */
61 | #define IN_CLASSA(a) IP_CLASSA(a)
62 | #define IN_CLASSA_NET IP_CLASSA_NET
63 | #define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT
64 | #define IN_CLASSA_HOST IP_CLASSA_HOST
65 | #define IN_CLASSA_MAX IP_CLASSA_MAX
66 |
67 | #define IN_CLASSB(b) IP_CLASSB(b)
68 | #define IN_CLASSB_NET IP_CLASSB_NET
69 | #define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT
70 | #define IN_CLASSB_HOST IP_CLASSB_HOST
71 | #define IN_CLASSB_MAX IP_CLASSB_MAX
72 |
73 | #define IN_CLASSC(c) IP_CLASSC(c)
74 | #define IN_CLASSC_NET IP_CLASSC_NET
75 | #define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT
76 | #define IN_CLASSC_HOST IP_CLASSC_HOST
77 | #define IN_CLASSC_MAX IP_CLASSC_MAX
78 |
79 | #define IN_CLASSD(d) IP_CLASSD(d)
80 | #define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */
81 | #define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */
82 | #define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */
83 | #define IN_CLASSD_MAX IP_CLASSD_MAX
84 |
85 | #define IN_MULTICAST(a) IP_MULTICAST(a)
86 |
87 | #define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a)
88 | #define IN_BADCLASS(a) IP_BADCLASS(a)
89 |
90 | #define IN_LOOPBACKNET IP_LOOPBACKNET
91 |
92 | #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
93 | #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
94 | /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */
95 | #define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr))
96 |
97 | /* directly map this to the lwip internal functions */
98 | #define inet_addr(cp) ipaddr_addr(cp)
99 | #define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr)
100 | #define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr))
101 | #define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen)
102 |
103 | #ifdef __cplusplus
104 | }
105 | #endif
106 |
107 | #endif /* __LWIP_INET_H__ */
108 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_FORCE_LEVEL)) { \
88 | LWIP_PLATFORM_DIAG(((s16_t)((debug) & LWIP_DBG_MASK_LEVEL)), message); \
89 | if ((debug) & LWIP_DBG_HALT) { \
90 | while(1); \
91 | } \
92 | } \
93 | } while(0)
94 |
95 | #else /* LWIP_DEBUG */
96 | #define LWIP_DEBUGF(debug, message)
97 | #endif /* LWIP_DEBUG */
98 |
99 | #endif /* __LWIP_DEBUG_H__ */
100 |
101 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/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 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/ipv4/lwip/autoip.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * AutoIP Automatic LinkLocal IP Configuration
5 | */
6 |
7 | /*
8 | *
9 | * Copyright (c) 2007 Dominik Spies
10 | * All rights reserved.
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice,
16 | * this list of conditions and the following disclaimer.
17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
18 | * this list of conditions and the following disclaimer in the documentation
19 | * and/or other materials provided with the distribution.
20 | * 3. The name of the author may not be used to endorse or promote products
21 | * derived from this software without specific prior written permission.
22 | *
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 | * OF SUCH DAMAGE.
33 | *
34 | * Author: Dominik Spies
35 | *
36 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
37 | * with RFC 3927.
38 | *
39 | *
40 | * Please coordinate changes and requests with Dominik Spies
41 | *
42 | */
43 |
44 | #ifndef __LWIP_AUTOIP_H__
45 | #define __LWIP_AUTOIP_H__
46 |
47 | #include "lwip/opt.h"
48 |
49 | #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
50 |
51 | #include "lwip/netif.h"
52 | #include "lwip/udp.h"
53 | #include "netif/etharp.h"
54 |
55 | #ifdef __cplusplus
56 | extern "C" {
57 | #endif
58 |
59 | /* AutoIP Timing */
60 | #define AUTOIP_TMR_INTERVAL 100
61 | #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
62 |
63 | /* RFC 3927 Constants */
64 | #define PROBE_WAIT 1 /* second (initial random delay) */
65 | #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */
66 | #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */
67 | #define PROBE_NUM 3 /* (number of probe packets) */
68 | #define ANNOUNCE_NUM 2 /* (number of announcement packets) */
69 | #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */
70 | #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */
71 | #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */
72 | #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */
73 | #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */
74 |
75 | /* AutoIP client states */
76 | #define AUTOIP_STATE_OFF 0
77 | #define AUTOIP_STATE_PROBING 1
78 | #define AUTOIP_STATE_ANNOUNCING 2
79 | #define AUTOIP_STATE_BOUND 3
80 |
81 | struct autoip
82 | {
83 | ip_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */
84 | u8_t state; /* current AutoIP state machine state */
85 | u8_t sent_num; /* sent number of probes or announces, dependent on state */
86 | u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
87 | u8_t lastconflict; /* ticks until a conflict can be solved by defending */
88 | u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */
89 | };
90 |
91 |
92 | #define autoip_init() /* Compatibility define, no init needed. */
93 |
94 | /** Set a struct autoip allocated by the application to work with */
95 | void autoip_set_struct(struct netif *netif, struct autoip *autoip);
96 |
97 | /** Start AutoIP client */
98 | err_t autoip_start(struct netif *netif);
99 |
100 | /** Stop AutoIP client */
101 | err_t autoip_stop(struct netif *netif);
102 |
103 | /** Handles every incoming ARP Packet, called by etharp_arp_input */
104 | void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
105 |
106 | /** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
107 | void autoip_tmr(void);
108 |
109 | /** Handle a possible change in the network configuration */
110 | void autoip_network_changed(struct netif *netif);
111 |
112 | #ifdef __cplusplus
113 | }
114 | #endif
115 |
116 | #endif /* LWIP_AUTOIP */
117 |
118 | #endif /* __LWIP_AUTOIP_H__ */
119 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/netif/ppp/pap.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * pap.h - PPP Password Authentication Protocol 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 | * upap.h - User/Password Authentication Protocol 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 |
52 | #ifndef PAP_H
53 | #define PAP_H
54 |
55 | #if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
56 |
57 | /*
58 | * Packet header = Code, id, length.
59 | */
60 | #define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
61 |
62 |
63 | /*
64 | * UPAP codes.
65 | */
66 | #define UPAP_AUTHREQ 1 /* Authenticate-Request */
67 | #define UPAP_AUTHACK 2 /* Authenticate-Ack */
68 | #define UPAP_AUTHNAK 3 /* Authenticate-Nak */
69 |
70 | /*
71 | * Each interface is described by upap structure.
72 | */
73 | typedef struct upap_state {
74 | int us_unit; /* Interface unit number */
75 | const char *us_user; /* User */
76 | int us_userlen; /* User length */
77 | const char *us_passwd; /* Password */
78 | int us_passwdlen; /* Password length */
79 | int us_clientstate; /* Client state */
80 | int us_serverstate; /* Server state */
81 | u_char us_id; /* Current id */
82 | int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */
83 | int us_transmits; /* Number of auth-reqs sent */
84 | int us_maxtransmits; /* Maximum number of auth-reqs to send */
85 | int us_reqtimeout; /* Time to wait for auth-req from peer */
86 | } upap_state;
87 |
88 | /*
89 | * Client states.
90 | */
91 | #define UPAPCS_INITIAL 0 /* Connection down */
92 | #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */
93 | #define UPAPCS_PENDING 2 /* Connection down, have requested auth */
94 | #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */
95 | #define UPAPCS_OPEN 4 /* We've received an Ack */
96 | #define UPAPCS_BADAUTH 5 /* We've received a Nak */
97 |
98 | /*
99 | * Server states.
100 | */
101 | #define UPAPSS_INITIAL 0 /* Connection down */
102 | #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */
103 | #define UPAPSS_PENDING 2 /* Connection down, have requested auth */
104 | #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */
105 | #define UPAPSS_OPEN 4 /* We've sent an Ack */
106 | #define UPAPSS_BADAUTH 5 /* We've sent a Nak */
107 |
108 |
109 | extern upap_state upap[];
110 |
111 | void upap_authwithpeer (int, char *, char *);
112 | void upap_authpeer (int);
113 |
114 | extern struct protent pap_protent;
115 |
116 | #endif /* PAP_SUPPORT */
117 |
118 | #endif /* PAP_H */
119 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/lwip/netdb.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 | * Author: Simon Goldschmidt
27 | *
28 | */
29 | #ifndef __LWIP_NETDB_H__
30 | #define __LWIP_NETDB_H__
31 |
32 | #include "lwip/opt.h"
33 |
34 | #if LWIP_DNS && LWIP_SOCKET
35 |
36 | #include /* for size_t */
37 |
38 | #include "lwip/inet.h"
39 | #include "lwip/sockets.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | /* some rarely used options */
46 | #ifndef LWIP_DNS_API_DECLARE_H_ERRNO
47 | #define LWIP_DNS_API_DECLARE_H_ERRNO 1
48 | #endif
49 |
50 | #ifndef LWIP_DNS_API_DEFINE_ERRORS
51 | #define LWIP_DNS_API_DEFINE_ERRORS 1
52 | #endif
53 |
54 | #ifndef LWIP_DNS_API_DECLARE_STRUCTS
55 | #define LWIP_DNS_API_DECLARE_STRUCTS 1
56 | #endif
57 |
58 | #if LWIP_DNS_API_DEFINE_ERRORS
59 | /** Errors used by the DNS API functions, h_errno can be one of them */
60 | #define EAI_NONAME 200
61 | #define EAI_SERVICE 201
62 | #define EAI_FAIL 202
63 | #define EAI_MEMORY 203
64 |
65 | #define HOST_NOT_FOUND 210
66 | #define NO_DATA 211
67 | #define NO_RECOVERY 212
68 | #define TRY_AGAIN 213
69 | #endif /* LWIP_DNS_API_DEFINE_ERRORS */
70 |
71 | #if LWIP_DNS_API_DECLARE_STRUCTS
72 | struct hostent {
73 | char *h_name; /* Official name of the host. */
74 | char **h_aliases; /* A pointer to an array of pointers to alternative host names,
75 | terminated by a null pointer. */
76 | int h_addrtype; /* Address type. */
77 | int h_length; /* The length, in bytes, of the address. */
78 | char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
79 | network byte order) for the host, terminated by a null pointer. */
80 | #define h_addr h_addr_list[0] /* for backward compatibility */
81 | };
82 |
83 | struct addrinfo {
84 | int ai_flags; /* Input flags. */
85 | int ai_family; /* Address family of socket. */
86 | int ai_socktype; /* Socket type. */
87 | int ai_protocol; /* Protocol of socket. */
88 | socklen_t ai_addrlen; /* Length of socket address. */
89 | struct sockaddr *ai_addr; /* Socket address of socket. */
90 | char *ai_canonname; /* Canonical name of service location. */
91 | struct addrinfo *ai_next; /* Pointer to next in list. */
92 | };
93 | #endif /* LWIP_DNS_API_DECLARE_STRUCTS */
94 |
95 | #if LWIP_DNS_API_DECLARE_H_ERRNO
96 | /* application accessable error code set by the DNS API functions */
97 | extern int h_errno;
98 | #endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
99 |
100 | struct hostent *lwip_gethostbyname(const char *name);
101 | int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
102 | size_t buflen, struct hostent **result, int *h_errnop);
103 | void lwip_freeaddrinfo(struct addrinfo *ai);
104 | int lwip_getaddrinfo(const char *nodename,
105 | const char *servname,
106 | const struct addrinfo *hints,
107 | struct addrinfo **res);
108 |
109 | #if LWIP_COMPAT_SOCKETS
110 | #define gethostbyname(name) lwip_gethostbyname(name)
111 | #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
112 | lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
113 | #define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
114 | #define getaddrinfo(nodname, servname, hints, res) \
115 | lwip_getaddrinfo(nodname, servname, hints, res)
116 | #endif /* LWIP_COMPAT_SOCKETS */
117 |
118 | #ifdef __cplusplus
119 | }
120 | #endif
121 |
122 | #endif /* LWIP_DNS && LWIP_SOCKET */
123 |
124 | #endif /* __LWIP_NETDB_H__ */
125 |
--------------------------------------------------------------------------------
/freertos/FreeRTOS/inc/os/alt_flag.h:
--------------------------------------------------------------------------------
1 | #ifndef __ALT_FLAG_H__
2 | #define __ALT_FLAG_H__
3 |
4 | /******************************************************************************
5 | * *
6 | * License Agreement *
7 | * *
8 | * Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
9 | * All rights reserved. *
10 | * *
11 | * Permission is hereby granted, free of charge, to any person obtaining a *
12 | * copy of this software and associated documentation files (the "Software"), *
13 | * to deal in the Software without restriction, including without limitation *
14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
15 | * and/or sell copies of the Software, and to permit persons to whom the *
16 | * Software is furnished to do so, subject to the following conditions: *
17 | * *
18 | * The above copyright notice and this permission notice shall be included in *
19 | * all copies or substantial portions of the Software. *
20 | * *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
27 | * DEALINGS IN THE SOFTWARE. *
28 | * *
29 | * This agreement shall be governed in all respects by the laws of the State *
30 | * of California and by the laws of the United States of America. *
31 | * *
32 | * Altera does not recommend, suggest or require that this reference design *
33 | * file be used in conjunction or combination with any other product. *
34 | ******************************************************************************/
35 |
36 | /******************************************************************************
37 | * *
38 | * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
39 | * *
40 | ******************************************************************************/
41 |
42 | /*
43 | * This header provides macro definitions that can be used to create and use
44 | * uc/OS-II style event flags. These macros can be used in both a uC/OS-II based
45 | * environment, and a single threaded HAL based environment.
46 | *
47 | * The motivation for these macros is to allow code to be developed which is
48 | * thread safe under uC/OS-II, but incurs no additional overhead when used in a
49 | * single threaded HAL environment.
50 | *
51 | * In the case of a single threaded HAL environment, they compile to
52 | * "do nothing" directives, which ensures they do not contribute to the final
53 | * executable.
54 | *
55 | * The following macros are available:
56 | *
57 | * ALT_FLAG_GRP - Create a flag group instance.
58 | * ALT_EXTERN_FLAG_GRP - Create a reference to an external flag group instance.
59 | * ALT_STATIC_FLAG_GRP - Create a static flag group instance.
60 | * ALT_FLAG_CREATE - Initialise a flag group.
61 | * ALT_FLAG_PEND - Pend on a flag group.
62 | * ALT_FLAG_POST - Set a flag condition.
63 |
64 | *
65 | * Input arguments and return codes are all consistant with the equivalent
66 | * uC/OS-II function.
67 | *
68 | * It's important to be careful in the use of the macros: ALT_FLAG_GRP,
69 | * ALT_EXTERN_FLAG_GRP, and ALT_STATIC_FLAG_GRP. In these three cases the
70 | * semi-colon is included in the macro definition; so, for example, you should
71 | * use:
72 | *
73 | * ALT_FLAG_GRP(mygroup)
74 | *
75 | * not:
76 | *
77 | * ALT_FLAG_GRP(mygroup);
78 | *
79 | * The inclusion of the semi-colon has been necessary to ensure the macros can
80 | * compile with no warnings when used in a single threaded HAL environment.
81 | *
82 | */
83 |
84 | #include "priv/alt_no_error.h"
85 |
86 | #define ALT_FLAG_GRP(group)
87 | #define ALT_EXTERN_FLAG_GRP(group)
88 | #define ALT_STATIC_FLAG_GRP(group)
89 |
90 | #define ALT_FLAG_CREATE(group, flags) alt_no_error ()
91 | #define ALT_FLAG_PEND(group, flags, wait_type, timeout) alt_no_error ()
92 | #define ALT_FLAG_POST(group, flags, opt) alt_no_error ()
93 |
94 | #ifndef ALT_SINGLE_THREADED
95 | #define ALT_SINGLE_THREADED
96 | #endif
97 |
98 | #endif /* __ALT_FLAG_H__ */
99 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/netif/ppp/ipcp.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * ipcp.h - PPP IP NCP: Internet Protocol Network Control Protocol 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 | * ipcp.h - IP Control Protocol 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: ipcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $
52 | */
53 |
54 | #ifndef IPCP_H
55 | #define IPCP_H
56 |
57 | /*
58 | * Options.
59 | */
60 | #define CI_ADDRS 1 /* IP Addresses */
61 | #define CI_COMPRESSTYPE 2 /* Compression Type */
62 | #define CI_ADDR 3
63 |
64 | #define CI_MS_DNS1 129 /* Primary DNS value */
65 | #define CI_MS_WINS1 128 /* Primary WINS value */
66 | #define CI_MS_DNS2 131 /* Secondary DNS value */
67 | #define CI_MS_WINS2 130 /* Secondary WINS value */
68 |
69 | #define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
70 | #define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
71 | #define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
72 | /* maxslot and slot number compression) */
73 |
74 | #define IPCP_VJ_COMP 0x002d /* current value for VJ compression option */
75 | #define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
76 | /* compression option */
77 |
78 | typedef struct ipcp_options {
79 | u_int neg_addr : 1; /* Negotiate IP Address? */
80 | u_int old_addrs : 1; /* Use old (IP-Addresses) option? */
81 | u_int req_addr : 1; /* Ask peer to send IP address? */
82 | u_int default_route : 1; /* Assign default route through interface? */
83 | u_int proxy_arp : 1; /* Make proxy ARP entry for peer? */
84 | u_int neg_vj : 1; /* Van Jacobson Compression? */
85 | u_int old_vj : 1; /* use old (short) form of VJ option? */
86 | u_int accept_local : 1; /* accept peer's value for ouraddr */
87 | u_int accept_remote : 1; /* accept peer's value for hisaddr */
88 | u_int req_dns1 : 1; /* Ask peer to send primary DNS address? */
89 | u_int req_dns2 : 1; /* Ask peer to send secondary DNS address? */
90 | u_short vj_protocol; /* protocol value to use in VJ option */
91 | u_char maxslotindex; /* VJ slots - 1. */
92 | u_char cflag; /* VJ slot compression flag. */
93 | u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
94 | u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
95 | u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
96 | } ipcp_options;
97 |
98 | extern fsm ipcp_fsm[];
99 | extern ipcp_options ipcp_wantoptions[];
100 | extern ipcp_options ipcp_gotoptions[];
101 | extern ipcp_options ipcp_allowoptions[];
102 | extern ipcp_options ipcp_hisoptions[];
103 |
104 | extern struct protent ipcp_protent;
105 |
106 | #endif /* IPCP_H */
107 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/src/api/netifapi.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Network Interface Sequential API module
4 | *
5 | */
6 |
7 | /*
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice,
12 | * this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | * 3. The name of the author may not be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28 | * OF SUCH DAMAGE.
29 | *
30 | * This file is part of the lwIP TCP/IP stack.
31 | *
32 | */
33 |
34 | #include "lwip/opt.h"
35 |
36 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
37 |
38 | #include "lwip/netifapi.h"
39 | #include "lwip/tcpip.h"
40 |
41 | /**
42 | * Call netif_add() inside the tcpip_thread context.
43 | */
44 | void
45 | do_netifapi_netif_add(struct netifapi_msg_msg *msg)
46 | {
47 | if (!netif_add( msg->netif,
48 | msg->msg.add.ipaddr,
49 | msg->msg.add.netmask,
50 | msg->msg.add.gw,
51 | msg->msg.add.state,
52 | msg->msg.add.init,
53 | msg->msg.add.input)) {
54 | msg->err = ERR_IF;
55 | } else {
56 | msg->err = ERR_OK;
57 | }
58 | TCPIP_NETIFAPI_ACK(msg);
59 | }
60 |
61 | /**
62 | * Call netif_set_addr() inside the tcpip_thread context.
63 | */
64 | void
65 | do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg)
66 | {
67 | netif_set_addr( msg->netif,
68 | msg->msg.add.ipaddr,
69 | msg->msg.add.netmask,
70 | msg->msg.add.gw);
71 | msg->err = ERR_OK;
72 | TCPIP_NETIFAPI_ACK(msg);
73 | }
74 |
75 | /**
76 | * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
77 | * tcpip_thread context.
78 | */
79 | void
80 | do_netifapi_netif_common(struct netifapi_msg_msg *msg)
81 | {
82 | if (msg->msg.common.errtfunc != NULL) {
83 | msg->err = msg->msg.common.errtfunc(msg->netif);
84 | } else {
85 | msg->err = ERR_OK;
86 | msg->msg.common.voidfunc(msg->netif);
87 | }
88 | TCPIP_NETIFAPI_ACK(msg);
89 | }
90 |
91 | /**
92 | * Call netif_add() in a thread-safe way by running that function inside the
93 | * tcpip_thread context.
94 | *
95 | * @note for params @see netif_add()
96 | */
97 | err_t
98 | netifapi_netif_add(struct netif *netif,
99 | ip_addr_t *ipaddr,
100 | ip_addr_t *netmask,
101 | ip_addr_t *gw,
102 | void *state,
103 | netif_init_fn init,
104 | netif_input_fn input)
105 | {
106 | struct netifapi_msg msg;
107 | msg.function = do_netifapi_netif_add;
108 | msg.msg.netif = netif;
109 | msg.msg.msg.add.ipaddr = ipaddr;
110 | msg.msg.msg.add.netmask = netmask;
111 | msg.msg.msg.add.gw = gw;
112 | msg.msg.msg.add.state = state;
113 | msg.msg.msg.add.init = init;
114 | msg.msg.msg.add.input = input;
115 | TCPIP_NETIFAPI(&msg);
116 | return msg.msg.err;
117 | }
118 |
119 | /**
120 | * Call netif_set_addr() in a thread-safe way by running that function inside the
121 | * tcpip_thread context.
122 | *
123 | * @note for params @see netif_set_addr()
124 | */
125 | err_t
126 | netifapi_netif_set_addr(struct netif *netif,
127 | ip_addr_t *ipaddr,
128 | ip_addr_t *netmask,
129 | ip_addr_t *gw)
130 | {
131 | struct netifapi_msg msg;
132 | msg.function = do_netifapi_netif_set_addr;
133 | msg.msg.netif = netif;
134 | msg.msg.msg.add.ipaddr = ipaddr;
135 | msg.msg.msg.add.netmask = netmask;
136 | msg.msg.msg.add.gw = gw;
137 | TCPIP_NETIFAPI(&msg);
138 | return msg.msg.err;
139 | }
140 |
141 | /**
142 | * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
143 | * way by running that function inside the tcpip_thread context.
144 | *
145 | * @note use only for functions where there is only "netif" parameter.
146 | */
147 | err_t
148 | netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
149 | netifapi_errt_fn errtfunc)
150 | {
151 | struct netifapi_msg msg;
152 | msg.function = do_netifapi_netif_common;
153 | msg.msg.netif = netif;
154 | msg.msg.msg.common.voidfunc = voidfunc;
155 | msg.msg.msg.common.errtfunc = errtfunc;
156 | TCPIP_NETIFAPI(&msg);
157 | return msg.msg.err;
158 | }
159 |
160 | #endif /* LWIP_NETIF_API */
161 |
--------------------------------------------------------------------------------
/freertos/build/app.mk:
--------------------------------------------------------------------------------
1 | # ******************************************************************************
2 | # * *
3 | # * License Agreement *
4 | # * *
5 | # * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
6 | # * All rights reserved. *
7 | # * *
8 | # * Permission is hereby granted, free of charge, to any person obtaining a *
9 | # * copy of this software and associated documentation files (the "Software"), *
10 | # * to deal in the Software without restriction, including without limitation *
11 | # * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 | # * and/or sell copies of the Software, and to permit persons to whom the *
13 | # * Software is furnished to do so, subject to the following conditions: *
14 | # * *
15 | # * The above copyright notice and this permission notice shall be included in *
16 | # * all copies or substantial portions of the Software. *
17 | # * *
18 | # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 | # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 | # * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE*
21 | # * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 | # * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
23 | # * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
24 | # * DEALINGS IN THE SOFTWARE. *
25 | # * *
26 | # * This agreement shall be governed in all respects by the laws of the State *
27 | # * of California and by the laws of the United States of America. *
28 | # * *
29 | # * Altera does not recommend, suggest or require that this reference design *
30 | # * file be used in conjunction or combination with any other product. *
31 | # ******************************************************************************
32 |
33 | # This makefile is included into the top level makefile for application
34 | # projects. It is responsible for defining the rules used to build the project.
35 | #
36 | # In practice this file defers the rule definitions to the included file,
37 | # app_rules.mk. This makefile restricts itself to simply configuring some
38 | # variables required by app_rules.mk, and including the makefile fragments
39 | # supplied by each component.
40 | #
41 | # The key feature of this makefile is that it includes the auto-generated
42 | # makefile, generated_all.mk, to obtain a list of the components built into
43 | # the library. This file defines four lists of components being used,
44 | # which are combined here to form the COMPONENTS variable.
45 | #
46 | # COMPONENTS is then used to construct: the include search path, and a list of
47 | # the makefile fragments supplied by the components (which are then included).
48 |
49 | # specify the flavour of system that's being built
50 |
51 | SYSTEM = freertos
52 |
53 | # specify that we're an application Makefile
54 |
55 | PROJ_TYPE = app
56 |
57 | # The system library build directory
58 |
59 | SYSTEM_CONFIG_DIR = $(SYSTEM_DIR)/$(SYS_CONFIG)
60 |
61 | # The directory in which all gtf generated files are stored
62 |
63 | GTF_GENERATED = $(SYSTEM_CONFIG_DIR)/system_description
64 |
65 | # Include the auto-generated list of components.
66 |
67 | -include $(GTF_GENERATED)/generated_all.mk
68 |
69 | # combine all these that were set in generated_all.mk
70 |
71 | COMPONENTS = $(COMPONENTS_SOFTWARE) \
72 | $(COMPONENTS_DEVICE_DRIVERS) \
73 | $(COMPONENTS_PROCESSOR) \
74 | $(COMPONENTS_OS)
75 |
76 | # Add on the HAL component
77 |
78 | CYGPATH_U = $(shell if [ "X`which cygpath.exe 2> /dev/null`" != "X" ]; \
79 | then echo "cygpath -u"; else echo "echo"; fi)
80 |
81 | COMPONENTS += $(shell $(CYGPATH_U) "$(SOPC_KIT_NIOS2)/components/altera_hal")
82 |
83 | # Construct the source searchpath.
84 | #
85 | # Source files are listed relative to the project directory, which is the
86 | # parent directory for the current directory.
87 |
88 | VPATH = ..
89 |
90 | # Construct the include path based on the available components
91 |
92 | INC_DIRS = $(wildcard $(foreach component, $(COMPONENTS), \
93 | $(component)/FreeRTOS/inc $(component)/HAL/inc $(component)/inc))
94 |
95 | CPPFLAGS += -I.. -I$(GTF_GENERATED) \
96 | $(foreach dir, $(INCLUDE_PATH), -I$(dir)) \
97 | $(foreach dir, $(INC_DIRS), -I$(dir))
98 |
99 | # Construct a list of the component makefiles
100 |
101 | COMPONENT_MAKEFILES = $(wildcard $(foreach component,$(COMPONENTS), \
102 | $(component)/FreeRTOS/src/component.mk \
103 | $(component)/HAL/src/component.mk))
104 |
105 | # Say that we still support the HAL API
106 |
107 | CPPFLAGS += -D__hal__
108 |
109 | # Include the rules used to build application projects
110 |
111 | include $(SOPC_KIT_NIOS2)/components/altera_hal/build/app_rules.mk
112 |
--------------------------------------------------------------------------------
/lwip/FreeRTOS/inc/arch/cc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011-2012, Engineering Spirit NL
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 port for NIOS II with FreeRTOS
30 | *
31 | * FreeRTOS support included by Engineering Spirit (c) 2012 http://engineering-spirit.nl/
32 | */
33 | #ifndef __CC_H__
34 | #define __CC_H__
35 |
36 | // CLib includes
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | // Altera HAL includes
43 | #include
44 | #include
45 |
46 | #define LWIP_NOASSERT 1
47 | //#define LWIP_DEBUG 1
48 |
49 | // Set altera typedefs for LwIP (in-case someone chooses a word size different from 32bits)
50 | typedef alt_u8 u8_t;
51 | typedef alt_8 s8_t;
52 | typedef alt_u16 u16_t;
53 | typedef alt_16 s16_t;
54 | typedef alt_u32 u32_t;
55 | typedef alt_32 s32_t;
56 |
57 | typedef u32_t mem_ptr_t;
58 | typedef u32_t ipaddr_t;
59 |
60 | // Set printf formats
61 | #define U16_F "hu"
62 | #define X16_F "hX"
63 | #define U32_F "lu"
64 | #define X32_F "lX"
65 | #define S16_F "hd"
66 | #define S32_F "ld"
67 |
68 | // NIOS II is configured as Little Endian most of the time however we also want to support a Big Endian CPU
69 | #if NIOS2_BIG_ENDIAN == 1 // we don't need to swap
70 | # define BYTE_ORDER BIG_ENDIAN
71 | # define htonl(l) (l)
72 | # define htons(s) (s)
73 | # define ntohl(l) (l)
74 | # define ntohs(s) (s)
75 | #else // we need to swap
76 | # define BYTE_ORDER LITTLE_ENDIAN
77 | # define htons(s) ((((s) & 0xFF00) >> 8) | \
78 | (((s) & 0x00FF) << 8))
79 |
80 | # define htonl(l) (((((l) >> 24) & 0x000000FF)) | \
81 | ((((l) >> 8) & 0x0000FF00)) | \
82 | (((l) & 0x0000FF00) << 8) | \
83 | (((l) & 0x000000FF) << 24))
84 |
85 | # define ntohs(s) (htons(s))
86 | # define ntohl(l) (htonl(l))
87 | #endif
88 |
89 | // Avoid naming collision for our network byte swap functions
90 | #define LWIP_PREFIX_BYTEORDER_FUNCS 1
91 | #define LWIP_PLATFORM_BYTESWAP 1
92 |
93 | // Now define the macro's so our byte swap functions will be used
94 | #define LWIP_PLATFORM_HTONL(l) (htonl(l))
95 | #define LWIP_PLATFORM_HTONS(s) (htons(s))
96 | #define LWIP_PLATFORM_NTOHL(l) (ntohl(l))
97 | #define LWIP_PLATFORM_NTOHS(s) (ntohs(s))
98 |
99 | // GCC packing is straight forward
100 | #define PACK_STRUCT_BEGIN
101 | #define PACK_STRUCT_STRUCT __attribute__((packed))
102 | #define PACK_STRUCT_END
103 | #define PACK_STRUCT_FIELD(x) x
104 |
105 | // Some GCC attributes for better readability
106 | #if __GNUC__ >= 3
107 | # ifndef __unused
108 | # define __unused __attribute__((unused))
109 | # endif
110 |
111 | # ifndef __noinline
112 | # define __noinline __attribute__((noinline))
113 | # endif
114 | #else
115 | # ifndef __unused
116 | # define __unused /* not supported */
117 | # endif
118 |
119 | # ifndef __noinline
120 | # define __noinline /* not supported */
121 | # endif
122 | #endif
123 |
124 | // We use the default printf functionality from the BSP package
125 | # define LWIP_PLATFORM_DIAG(lvl, x) do { \
126 | if ((lvl) >= LWIP_DBG_FORCE_LEVEL) { \
127 | printf(((lvl) == LWIP_DBG_LEVEL_WARNING) ? "!! WARNING !! " : ((lvl) == LWIP_DBG_LEVEL_SERIOUS) ? "!! SERIOUS !! " : "!! SEVERE !! "); \
128 | } \
129 | printf x; \
130 | } while(0)
131 |
132 | // TODO And we call exit (which calls ALT_EXIT on it's turn for nice process termination)
133 | # define LWIP_PLATFORM_ASSERT(x) do { printf("[LwIP] Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); while (1); /* exit(1); */ } while(0)
134 |
135 | // Redefine memory align functionality
136 | #define LWIP_MEM_ALIGN(addr) ((void *)((((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))))
137 |
138 | // Some default math stuff
139 | #ifndef KB
140 | # define KB(x) ((x) * 1024)
141 | #endif
142 | #ifndef MB
143 | # define MB(x) (KB(x) * 1024)
144 | #endif
145 | #ifndef ABS
146 | # define ABS(x) ((x) >= 0 ? (x) : -(x))
147 | #endif
148 |
149 | #endif /* __CC_H__ */
150 |
--------------------------------------------------------------------------------